-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
http2: use session not socket timeout, tests
Change default timeout to be tracked on the session instead of the socket, as nghttp2 manages the socket and we would need to maintain two sets of timeouts for similar purpose. Also fixes session setTimeout to work as it wasn't getting _unrefActive correctly (was called on the handle). Fixes: #15158 PR-URL: #15188 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
- Loading branch information
1 parent
764213c
commit 93a4cf6
Showing
2 changed files
with
82 additions
and
41 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,41 @@ | ||
// Flags: --expose-http2 | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
if (!common.hasCrypto) | ||
common.skip('missing crypto'); | ||
const h2 = require('http2'); | ||
|
||
const serverTimeout = common.platformTimeout(200); | ||
const callTimeout = common.platformTimeout(10); | ||
|
||
const server = h2.createServer(); | ||
server.timeout = serverTimeout; | ||
|
||
server.on('request', (req, res) => res.end()); | ||
server.on('timeout', common.mustNotCall()); | ||
|
||
server.listen(0, common.mustCall(() => { | ||
const port = server.address().port; | ||
|
||
const url = `http://localhost:${port}`; | ||
const client = h2.connect(url); | ||
makeReq(40); | ||
|
||
function makeReq(attempts) { | ||
const request = client.request({ | ||
':path': '/foobar', | ||
':method': 'GET', | ||
':scheme': 'http', | ||
':authority': `localhost:${port}`, | ||
}); | ||
request.end(); | ||
|
||
if (attempts) { | ||
setTimeout(() => makeReq(attempts - 1), callTimeout); | ||
} else { | ||
server.close(); | ||
client.destroy(); | ||
} | ||
} | ||
})); |