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

Response event 'close' not emitted when request canceled on client-side #66

Closed
bulletinmybeard opened this issue Apr 24, 2022 · 1 comment

Comments

@bulletinmybeard
Copy link

bulletinmybeard commented Apr 24, 2022

First of all, thanks for HE, it's a pretty neat package!!!

I've been playing around with hyper-express lately and created a middleware to log slow requests. While working on that, I noticed that canceling requests on the client-side doesn't trigger the close event.

This test project was set up with:

  • Node (v17.6.0)
  • hyper-express (v5.9.2)
  • Express (v4.17.3)

Express.js example
https://gist.github.com/bulletinmybeard/02f5be3e2a9e8e92bbed6b8976ec42bb

// Not canceled
GET /slow [STARTED]
timeout cleared
GET /slow [FINISHED] 5,010.347 ms
GET /slow [CLOSED] 5,038.359 ms

-

// Canceled
GET /slow [STARTED]
GET /slow [CLOSED] 1,979.817 ms
timeout cleared

Hyper-Express example
https://gist.github.com/bulletinmybeard/f5620ba22a32d4e2bc020f72cb0f2d1e

// Not canceled
GET /slow [STARTED]
timeout cleared
GET /slow [FINISHED] 5,003.439 ms
GET /slow [CLOSED] 5,033.814 ms

-
// Canceled
GET /slow [STARTED]
timeout cleared

Cheers \w

@kartikk221
Copy link
Owner

Hey! I'm glad you like the package. So the whole event system is getting re-done in the upcoming 6.0.0 update which will be released soon in which the network events follow the Node.js spec (Same as Express.js) with some additional events implemented on top. If you would like to achieve this with the current version, You can set a hook/event handler for the "disconnect" event as that event is triggered for both a client-side abort or server-side response completion.

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

No branches or pull requests

2 participants