-
-
Notifications
You must be signed in to change notification settings - Fork 938
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
Regression handling multiple request errors #1224
Comments
That is correct. Please note, that starting Node.js 14.0.0 the recommended approach to |
It is intended. It leads to more strict behavior. But you're right, it should've been mentioned in the changelog. |
Please see the following: nodejs/node#32995 (comment) |
Thanks for the response. For other folks coming here, the relevant bit of the docs linked above for
This question might be better suited for the Node issue thread, but I'm hoping to pick @szmarczak brain. Because the following throws an uncaught error event, even in v14. const req = http.get("http://example.com")
req.on("socket", () => req.destroy()) |
Because the Node.js maintainers haven't fixed it yet / didn't have the time to do so. Note that it is a big project. You can find many bugs in Node.js, not only this. /cc @ronag |
Because Node has a lot of old code which is not trivial to re-write to use pragmatic streams. It should use If you look at the changlog for v13 and v14 we have fixed a lot of these cases in core and are working to sort out even more. |
That works as expected. Why is this strange?
|
I understand the work in progress, makes perfect sense.
With Node's current implementation, I agree that an uncaught error is expected. |
You can't end/stop a request and be guaranteed to not receive an error. |
Understood. How do I end a request without causing an error? |
|
Sorry, I'm not worried about guaranteeing an error or multiple errors won't happen, nor if they're uncaught if they do happen. |
Not possible unfortunately. |
Does the design of the work in progress (using |
The current behavior is desired. |
Thanks for your time @ronag |
Describe the bug
Starting with v11.0, emitting more than one error on the
ClientRequest
causes an unhandled error event.Code to reproduce
Actual behavior
Expected behavior
Previous behavior was to reject the promise with the first error, but each subsequent error would still run through the beforeError hook and propagate the event.
Not sure if that is the right behavior, but it probably is.
Regardless, looking at the changelog, this new behavior seems to be an unintended change.
I'm sure @szmarczak will know off hand, but this seems to have been caused by the "Rewrite Got" aligning on using
request.once
instead of usingrequest.on
in request-as-event-emitter.ts.One thing to note about the 'code to reproduce' above is that the errors are emitted between the
socket
andresponse
events. This was identified because it broke Nock's test suite when upgrading to Got 11. nock/nock#1992Nock emits the "Nock: No match for request" error between those two events, Got then calls
abort
on the ClientRequest which emits a "socket hang up" error.The same behavior can seen with the 'code to reproduce' by commented out the second call to
emit
.Checklist
The text was updated successfully, but these errors were encountered: