Skip to content

Commit

Permalink
test: verify order of error in h2 server stream
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
MylesBorins committed Nov 27, 2018
1 parent 1db808c commit 51ed353
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions test/parallel/test-http2-error-order.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
'use strict';

const common = require('../common');
if (!common.hasCrypto)
common.skip('missing crypto');

const assert = require('assert');
const { createServer, connect } = require('http2');

const messages = [];
const expected = [
'Stream:created',
'Stream:error',
'Stream:close',
'Request:error'
];

const server = createServer();

server.on('stream', (stream) => {
messages.push('Stream:created');
stream
.on('close', () => messages.push('Stream:close'))
.on('error', (err) => messages.push('Stream:error'))
.respondWithFile('dont exist');
});

server.listen(8000);

const client = connect('http://localhost:8000');
const req = client.request();

req.on('response', common.mustNotCall());

req.on('error', () => {
messages.push('Request:error');
client.close();
});

client.on('close', () => {
assert.deepStrictEqual(messages, expected);
server.close();
});

0 comments on commit 51ed353

Please sign in to comment.