-
Notifications
You must be signed in to change notification settings - Fork 84
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
middleware not executing after request is complete #277
Comments
I've worked around the issues: diff --git a/src/components/router/Route.js b/src/components/router/Route.js
index 97c7e12a1f52484d7dcedba9b3599126420997c2..087d86fb24c5b78842bcea6fc83880372efccb49 100644
--- a/src/components/router/Route.js
+++ b/src/components/router/Route.js
@@ -67,9 +67,6 @@ class Route {
* @param {Number=} cursor The middleware cursor.
*/
handle(request, response, cursor = 0) {
- // Do not handle the request if the response has been sent aka. the request is no longer active
- if (response.completed) return;
-
// Retrieve the middleware for the current cursor, track the cursor if there is a valid middleware
let iterator;
const middleware = this.options.middlewares[cursor]; This patch makes it so the middleware chain doesn't stop when the request is completed. If this behavior is desirable in general (I don't see why not), it's probably a very easy change to make.
|
Hey, HyperExpress stops executing requests / middlewares If the request is disconnected or closed during traversal. This is a decision primarily made due to the expected behavior of request always being connected while execution of middlewares and also to prevent accidental bugs from calling With that said, the patch on that line should do the trick to allow for the behavior your want. Just be careful that most Request/Response methods become no-ops under the hood once a response is completed and some may still cause an error If they somehow end up trying to call the underlying |
I'm facing 2 issues:
next
is calledThe text was updated successfully, but these errors were encountered: