Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Add tests to replicate failure for afterMiddleware on success #53

Closed
wants to merge 1 commit into from
Closed

[WIP] Add tests to replicate failure for afterMiddleware on success #53

wants to merge 1 commit into from

Conversation

sivakumar-kailasam
Copy link

@sivakumar-kailasam sivakumar-kailasam commented Mar 25, 2017

This replicates the issue mentioned in #44. The afterMiddleware will be called whenever there's an error but not when the request is successful because of two reasons.

  1. On failure, the afterMiddleware that includes four arguments in the middleware acts as the error handler as per express. So whenever there's a failure in the express router, this will be called.

  2. On success, the fastboot middleware doesn't call next() to invoke this middleware but finishes off with a send(). But then again the user must have configured the middleware with 3 arguments for the middleware to be invoked.

May be it makes more sense if the afterMiddleware gets separated into an error handler and an afterResponseHook. Users need to be educated that the afterResponseHook is useful only to run operations such as logging, do post request db operations and not meant to modify the response since with send() we're past that.

I started looking into this issue since @rwjblue suggested we can use the afterMiddleware hook to set the cache control headers for the assets folder content. It's 0 by default now. I've raised #52 for that.

If we can figure out a way forward, I can help land that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant