镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
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 <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 288a421 commit e74345b

1 file changed

Lines changed: 43 additions & 0 deletions

File tree

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(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)