summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGerhard Stoebich <18708370+Flarna@users.noreply.github.com>2018-12-02 19:27:06 +0100
committerBeth Griggs <Bethany.Griggs@uk.ibm.com>2018-12-11 16:28:47 +0000
commit4c24a82a654e1d9561af5e47ad98a31c34bca5c3 (patch)
tree27148a54da5f86e6594633c5b967110380033156
parent394cb42962f542127ab3e8309d3143319ab44226 (diff)
downloadnode-new-4c24a82a654e1d9561af5e47ad98a31c34bca5c3.tar.gz
http2: fix sequence of error/close events
Correct sequence of emitting `error` and `close` events for a `Http2Stream`. PR-URL: https://github.com/nodejs/node/pull/24789 Refs: https://github.com/nodejs/node/pull/22850 Refs: https://github.com/nodejs/node/pull/24685 Fixes: https://github.com/nodejs/node/issues/24559 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
-rw-r--r--lib/internal/http2/core.js3
-rw-r--r--test/parallel/test-http2-stream-destroy-event-order.js9
2 files changed, 5 insertions, 7 deletions
diff --git a/lib/internal/http2/core.js b/lib/internal/http2/core.js
index 4c184fcfe1..055009d07c 100644
--- a/lib/internal/http2/core.js
+++ b/lib/internal/http2/core.js
@@ -1997,9 +1997,8 @@ class Http2Stream extends Duplex {
// will destroy if it has been closed and there are no other open or
// pending streams.
session[kMaybeDestroy]();
- process.nextTick(emit, this, 'close', code);
callback(err);
-
+ process.nextTick(emit, this, 'close', code);
}
// The Http2Stream can be destroyed if it has closed and if the readable
// side has received the final chunk.
diff --git a/test/parallel/test-http2-stream-destroy-event-order.js b/test/parallel/test-http2-stream-destroy-event-order.js
index 7d4bcb102f..88e4a99f99 100644
--- a/test/parallel/test-http2-stream-destroy-event-order.js
+++ b/test/parallel/test-http2-stream-destroy-event-order.js
@@ -1,4 +1,3 @@
-// Flags: --expose-http2
'use strict';
const common = require('../common');
@@ -10,8 +9,8 @@ let client;
let req;
const server = http2.createServer();
server.on('stream', common.mustCall((stream) => {
- stream.on('close', common.mustCall(() => {
- stream.on('error', common.mustCall(() => {
+ stream.on('error', common.mustCall(() => {
+ stream.on('close', common.mustCall(() => {
server.close();
}));
}));
@@ -22,8 +21,8 @@ server.listen(0, common.mustCall(() => {
client = http2.connect(`http://localhost:${server.address().port}`);
req = client.request();
req.resume();
- req.on('close', common.mustCall(() => {
- req.on('error', common.mustCall(() => {
+ req.on('error', common.mustCall(() => {
+ req.on('close', common.mustCall(() => {
client.close();
}));
}));