Skip to content
This repository was archived by the owner on Jul 6, 2018. It is now read-only.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 5473c35

Browse files
committedJul 10, 2017
http2: fixups after rebasing from nodejs/node master
1 parent 8ea8668 commit 5473c35

10 files changed

+25
-18
lines changed
 

‎lib/internal/http2/core.js

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
'use strict';
22

3+
/* eslint-disable no-use-before-define */
4+
35
const binding = process.binding('http2');
46
const debug = require('util').debuglog('http2');
57
const assert = require('assert');
@@ -2254,3 +2256,5 @@ module.exports = {
22542256
createSecureServer,
22552257
connect
22562258
};
2259+
2260+
/* eslint-enable no-use-before-define */

‎test/parallel/test-http2-client-stream-destroy-before-connect.js

+13-10
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,15 @@ const server = h2.createServer();
1212
// depending on the OS. The determination is based largely on operating
1313
// system specific timings
1414
server.on('stream', (stream) => {
15-
stream.on('error', common.expectsError({
16-
code: 'ERR_HTTP2_STREAM_ERROR',
17-
type: Error,
18-
message: 'Stream closed with error code 2'
19-
}));
15+
// Do not wrap in a must call or use common.expectsError (which now uses
16+
// must call). The error may or may not be reported depending on operating
17+
// system specific timings.
18+
stream.on('error', (err) => {
19+
if (err) {
20+
assert.strictEqual(err.code, 'ERR_HTTP2_STREAM_ERROR');
21+
assert.strictEqual(err.message, 'Stream closed with error code 2');
22+
}
23+
});
2024
stream.respond({});
2125
stream.end();
2226
});
@@ -31,19 +35,18 @@ server.on('listening', common.mustCall(() => {
3135
const err = new Error('test');
3236
req.destroy(err);
3337

34-
req.on('error', common.mustCall((e) => {
35-
if (e.code === 'ERR_HTTP2_STREAM_ERROR') {
38+
req.on('error', common.mustCall((err) => {
39+
const fn = err.code === 'ERR_HTTP2_STREAM_ERROR' ?
3640
common.expectsError({
3741
code: 'ERR_HTTP2_STREAM_ERROR',
3842
type: Error,
3943
message: 'Stream closed with error code 2'
40-
});
41-
} else {
44+
}) :
4245
common.expectsError({
4346
type: Error,
4447
message: 'test'
4548
});
46-
}
49+
fn(err);
4750
}, 2));
4851

4952
req.on('streamClosed', common.mustCall((code) => {

‎test/parallel/test-http2-compat-serverresponse-write-no-cb.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const { createServer, connect } = require('http2');
1010
const expectedError = expectsError({
1111
code: 'ERR_HTTP2_STREAM_CLOSED',
1212
message: 'The stream is already closed'
13-
});
13+
}, 2);
1414

1515
{
1616
const server = createServer();

‎test/parallel/test-http2-head-request.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const http2 = require('http2');
88
const errCheck = common.expectsError({
99
type: Error,
1010
message: 'write after end'
11-
});
11+
}, 2);
1212

1313
const {
1414
HTTP2_HEADER_PATH,

‎test/parallel/test-http2-priority-event.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ server.on('listening', common.mustCall(() => {
5050
req.on('priority', common.mustCall(onPriority));
5151

5252
req.on('response', common.mustCall());
53-
req.on('data', common.noop);
53+
req.resume();
5454
req.on('end', common.mustCall(() => {
5555
server.close();
5656
client.destroy();

‎test/parallel/test-http2-respond-file-fd-invalid.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const errorCheck = common.expectsError({
1313
code: 'ERR_HTTP2_STREAM_ERROR',
1414
type: Error,
1515
message: `Stream closed with error code ${NGHTTP2_INTERNAL_ERROR}`
16-
});
16+
}, 2);
1717

1818
const server = http2.createServer();
1919
server.on('stream', (stream) => {

‎test/parallel/test-http2-server-rst-stream.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const {
1616
NGHTTP2_INTERNAL_ERROR
1717
} = http2.constants;
1818

19-
const errCheck = common.expectsError({ code: 'ERR_HTTP2_STREAM_ERROR' });
19+
const errCheck = common.expectsError({ code: 'ERR_HTTP2_STREAM_ERROR' }, 8);
2020

2121
function checkRstCode(rstMethod, expectRstCode) {
2222
const server = http2.createServer();

‎test/parallel/test-http2-server-startup.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ assert.doesNotThrow(() => {
3333

3434
// There should not be any throws
3535
assert.doesNotThrow(() => {
36-
const server = http2.createServer(options, common.noop);
36+
const server = http2.createServer(options, common.mustNotCall());
3737

3838
server.listen(0, common.mustCall(() => server.close()));
3939

‎test/parallel/test-http2-session-settings.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ server.on('listening', common.mustCall(() => {
100100
}));
101101

102102
req.on('response', common.mustCall());
103-
req.on('data', common.noop);
103+
req.resume();
104104
req.on('end', common.mustCall(() => {
105105
server.close();
106106
client.destroy();

‎test/parallel/test-http2-session-stream-state.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ server.on('listening', common.mustCall(() => {
8787
}));
8888

8989
req.on('response', common.mustCall());
90-
req.on('data', common.noop);
90+
req.resume();
9191
req.on('end', common.mustCall(() => {
9292
server.close();
9393
client.destroy();

0 commit comments

Comments
 (0)
This repository has been archived.