Skip to content

Commit e74345b

Browse files
MylesBorinsBethGriggs
authored andcommitted
test: verify order of error in h2 server stream
Currently the order of error / closing of an h2 stream is consistent in 10.x, 11.x, and master. There appears to be an unexpected behavior difference in 8.x. This test will be used to bisect the commit that will fix this behavior change and ensure there are no future regressions. PR-URL: #24685 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 288a421 commit e74345b

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed
+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
'use strict';
2+
3+
const common = require('../common');
4+
if (!common.hasCrypto)
5+
common.skip('missing crypto');
6+
7+
const assert = require('assert');
8+
const { createServer, connect } = require('http2');
9+
10+
const messages = [];
11+
const expected = [
12+
'Stream:created',
13+
'Stream:error',
14+
'Stream:close',
15+
'Request:error'
16+
];
17+
18+
const server = createServer();
19+
20+
server.on('stream', (stream) => {
21+
messages.push('Stream:created');
22+
stream
23+
.on('close', () => messages.push('Stream:close'))
24+
.on('error', (err) => messages.push('Stream:error'))
25+
.respondWithFile('dont exist');
26+
});
27+
28+
server.listen(0);
29+
30+
const client = connect(`http://localhost:${server.address().port}`);
31+
const req = client.request();
32+
33+
req.on('response', common.mustNotCall());
34+
35+
req.on('error', () => {
36+
messages.push('Request:error');
37+
client.close();
38+
});
39+
40+
client.on('close', common.mustCall(() => {
41+
assert.deepStrictEqual(messages, expected);
42+
server.close();
43+
}));

0 commit comments

Comments
 (0)