Skip to content

Commit 51ed353

Browse files
committed
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.
1 parent 1db808c commit 51ed353

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed
Lines changed: 43 additions & 0 deletions
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(8000);
29+
30+
const client = connect('http://localhost:8000');
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', () => {
41+
assert.deepStrictEqual(messages, expected);
42+
server.close();
43+
});

0 commit comments

Comments
 (0)