-
-
Notifications
You must be signed in to change notification settings - Fork 35.4k
http: emit 'aborted' event for ClientRequest #15270
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
Fixes #15259
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -360,9 +360,10 @@ function socketCloseListener() { | |
| // NOTE: It's important to get parser here, because it could be freed by | ||
| // the `socketOnData`. | ||
| var parser = socket.parser; | ||
| req.emit('close'); | ||
|
|
||
| if (req.res && req.res.readable) { | ||
| // Socket closed before we emitted 'end' below. | ||
| req.emit('aborted'); | ||
| req.res.emit('aborted'); | ||
| var res = req.res; | ||
| res.on('end', function() { | ||
|
|
@@ -374,9 +375,12 @@ function socketCloseListener() { | |
| // receive a response. The error needs to | ||
| // fire on the request. | ||
| req.socket._hadError = true; | ||
| req.emit('aborted'); | ||
| req.emit('error', createHangUpError()); | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think aborted should at least be emitted after error in case someone removes their error listener after aborted? Anyone else?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm 👎 in not emitting an error here.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mcollina: aborted after or before error?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. aborted after.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed |
||
| } | ||
|
|
||
| req.emit('close'); | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this correct? I think new Promise((resolve, reject) => req.on('close', resolve).on('error', reject))Where the error is ignored since the promise is already resolved through |
||
|
|
||
| // Too bad. That output wasn't getting written. | ||
| // This is pretty terrible that it doesn't raise an error. | ||
| // Fixed better in v0.10 | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this correct? This branch means there's a response coming but we haven't received its end. I don't think this qualifies for an 'aborted' event for the request (only the response).
If this is motivated by how this works in h2, it's slightly different there because you have the request & response in one (duplex stream), instead of separate like with http1.
Then again, maybe I'm severely overthinking this.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, from an api user's perspective the response could conceptually be part of the request (think h2)?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think both behaviours make sense. I would prefer the h2 way just to avoid confusion.