-
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.
test: Http2Stream destroy server before shutdown
Refs: #14985
- Loading branch information
Showing
1 changed file
with
30 additions
and
0 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
test/parallel/test-http2-server-destroy-before-shutdown.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,30 @@ | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
if (!common.hasCrypto) | ||
common.skip('missing crypto'); | ||
const http2 = require('http2'); | ||
|
||
const server = http2.createServer(); | ||
|
||
// Test that ERR_HTTP2_INVALID_SESSION is thrown when a stream is destroyed | ||
// before calling stream.session.shutdown | ||
server.on('stream', common.mustCall((stream) => { | ||
stream.session.destroy(); | ||
common.expectsError( | ||
() => stream.session.shutdown(), | ||
{ | ||
type: Error, | ||
code: 'ERR_HTTP2_INVALID_SESSION', | ||
message: 'The session has been destroyed' | ||
} | ||
); | ||
})); | ||
|
||
server.listen(0, common.mustCall(() => { | ||
const client = http2.connect(`http://localhost:${server.address().port}`); | ||
|
||
const req = client.request(); | ||
req.resume(); | ||
req.on('end', common.mustCall(() => server.close())); | ||
})); |