-
Notifications
You must be signed in to change notification settings - Fork 30.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
http: emit timeout duration overflow warning sync
Emit the `TimeoutOverflowWarning` synchronously, even when still connecting, to get a better stack trace. With thanks to Anatoli Papirovski for providing helpful tips when writing the test. PR-URL: #18906 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
- Loading branch information
Showing
2 changed files
with
23 additions
and
0 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
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,21 @@ | ||
'use strict'; | ||
const common = require('../common'); | ||
const http = require('http'); | ||
const assert = require('assert'); | ||
|
||
// Checks that the setTimeout duration overflow warning is emitted | ||
// synchronously and therefore contains a meaningful stacktrace. | ||
|
||
process.on('warning', common.mustCall((warning) => { | ||
assert(warning.stack.includes(__filename)); | ||
})); | ||
|
||
const server = http.createServer((req, resp) => resp.end()); | ||
server.listen(common.mustCall(() => { | ||
http.request(`http://localhost:${server.address().port}`) | ||
.setTimeout(2 ** 40) | ||
.on('response', common.mustCall(() => { | ||
server.close(); | ||
})) | ||
.end(); | ||
})); |