-
Notifications
You must be signed in to change notification settings - Fork 30k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
http: don't double-fire the req error event
req.socket._hadError should be set before emitting the error event. PR-URL: #14659 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Tobias Nießen <[email protected]>
- Loading branch information
Showing
2 changed files
with
20 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
test/parallel/test-http-client-req-error-dont-double-fire.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
'use strict'; | ||
const assert = require('assert'); | ||
const http = require('http'); | ||
const common = require('../common'); | ||
|
||
// not exists host | ||
const host = '*'.repeat(256); | ||
const req = http.get({ host }); | ||
const err = new Error('mock unexpected code error'); | ||
req.on('error', common.mustCall(() => { | ||
throw err; | ||
})); | ||
|
||
process.on('uncaughtException', common.mustCall((e) => { | ||
assert.strictEqual(e, err); | ||
})); |
620ba41
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.
This is unrelated to the specified PR-URL, it should have been #14333.