-
-
Notifications
You must be signed in to change notification settings - Fork 36.2k
http: guard invalid timeout values in checkConnections #64506
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| 'use strict'; | ||
|
|
||
| require('../common'); | ||
| const assert = require('assert'); | ||
| const { spawnSync } = require('child_process'); | ||
|
|
||
| if (process.argv[2] === 'child') { | ||
| const { createServer } = require('http'); | ||
|
|
||
| const server = createServer({ | ||
| connectionsCheckingInterval: 1, | ||
| }, (_req, res) => { | ||
| res.end('ok'); | ||
| }); | ||
|
|
||
| server.headersTimeout = 'im-not-a-number'; | ||
|
|
||
| server.listen(0, '127.0.0.1', () => { | ||
| setTimeout(() => { | ||
| server.close(() => process.exit(0)); | ||
| }, 50); | ||
| }); | ||
| } else { | ||
| // Run the repro in a child so the native crash is observable without failing the whole run | ||
| const { signal, status, stderr } = spawnSync( | ||
| process.execPath, | ||
| [__filename, 'child'], | ||
| { encoding: 'utf8' }, | ||
| ); | ||
|
|
||
| assert.strictEqual(signal, null); | ||
| assert.strictEqual(status, 0, stderr); | ||
|
Comment on lines
+25
to
+32
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. These kinds of tests make me nervous 😅. Do we already have something similar in the repo for HTTP?
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. That makes two of us 😅 There are a few, like https://github.com/nodejs/node/blob/83410d6ac84e4e85cc4f385461c4f0716fd1f836/test/abort/test-http-parser-consume.js |
||
| } | ||
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.
Why not just check whether
.close()has been called? And that way we avoid the child partThere 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.
Because the buggy behaviour crashes the whole process at native level, so the JS assertion wouldn't run