-
Notifications
You must be signed in to change notification settings - Fork 30.4k
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
doc,test: add server.timeout property to http2 public API #31693
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
Both http and https modules have server.timeout property in public API. This commit adds documentation section and test for server.timeout in http2 module, so it becomes consistent with http and https. Also improves description of callback argument in documentation for server.setTimeout().
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,21 +5,27 @@ if (!common.hasCrypto) | |
common.skip('missing crypto'); | ||
const http2 = require('http2'); | ||
|
||
const server = http2.createServer(); | ||
server.setTimeout(common.platformTimeout(50)); | ||
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. Shouldn't we keep this as a separate test in this file since 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. At first I've moved it into a separate test, but I agree that it doesn't make a lot of sense in this case. Introduced additional assert in this very test. 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 what was meant was a separate test file. Calling 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. Original version of this PR included a separate test, but I have removed it and merged everything into a this test after receiving this comment. @mscdex could you check current code and tell me if that's what you wanted? 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. @mscdex could you check current code and tell me if that's what you wanted? I'm thinking of reverting this change, as it seems more logical to me to keep tests isolated. 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 have updated the test, so now it verifies both |
||
function testServerTimeout(setTimeoutFn) { | ||
const server = http2.createServer(); | ||
setTimeoutFn(server); | ||
|
||
const onServerTimeout = common.mustCall((session) => { | ||
session.close(); | ||
}); | ||
const onServerTimeout = common.mustCall((session) => { | ||
session.close(); | ||
}); | ||
|
||
server.on('stream', common.mustNotCall()); | ||
server.once('timeout', onServerTimeout); | ||
server.on('stream', common.mustNotCall()); | ||
server.once('timeout', onServerTimeout); | ||
|
||
server.listen(0, common.mustCall(() => { | ||
const url = `http://localhost:${server.address().port}`; | ||
const client = http2.connect(url); | ||
client.on('close', common.mustCall(() => { | ||
const client2 = http2.connect(url); | ||
client2.on('close', common.mustCall(() => server.close())); | ||
server.listen(0, common.mustCall(() => { | ||
const url = `http://localhost:${server.address().port}`; | ||
const client = http2.connect(url); | ||
client.on('close', common.mustCall(() => { | ||
const client2 = http2.connect(url); | ||
client2.on('close', common.mustCall(() => server.close())); | ||
})); | ||
})); | ||
})); | ||
} | ||
|
||
const timeout = common.platformTimeout(50); | ||
testServerTimeout((server) => server.setTimeout(timeout)); | ||
testServerTimeout((server) => server.timeout = timeout); |
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.
nit:
here and below
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.
The same text (
120s
) is also used inhttp.md
and will be used inhttps.md
once #31692 lands. So, it's better to wait until that PR lands and change text in all places simultaneously.