From ca933ce5778364b46d6a8ad6dd4dca456119b948 Mon Sep 17 00:00:00 2001 From: Anatoli Papirovski Date: Sat, 15 Sep 2018 10:36:55 -0700 Subject: [PATCH] http2: do not falsely emit 'aborted' on push A push stream should have its writable side closed upon receipt, to avoid emitting the 'aborted' event when the readable side is closed. Backport-PR-URL: https://github.com/nodejs/node/pull/22850 PR-URL: https://github.com/nodejs/node/pull/22878 Fixes: https://github.com/nodejs/node/issues/22851 Reviewed-By: Luigi Pinca Reviewed-By: Anna Henningsen Reviewed-By: Colin Ihrig Reviewed-By: Matteo Collina --- lib/internal/http2/core.js | 1 + test/parallel/test-http2-server-push-stream.js | 1 + 2 files changed, 2 insertions(+) diff --git a/lib/internal/http2/core.js b/lib/internal/http2/core.js index 69f498e3d0e1ef..dadbaefa9ce634 100644 --- a/lib/internal/http2/core.js +++ b/lib/internal/http2/core.js @@ -220,6 +220,7 @@ function onSessionHeaders(handle, id, cat, flags, headers) { } } else { stream = new ClientHttp2Stream(session, handle, id, opts); + stream.end(); } if (endOfStream) stream[kState].endAfterHeaders = true; diff --git a/test/parallel/test-http2-server-push-stream.js b/test/parallel/test-http2-server-push-stream.js index 69e74349475c42..74d41ba4b9c672 100644 --- a/test/parallel/test-http2-server-push-stream.js +++ b/test/parallel/test-http2-server-push-stream.js @@ -54,6 +54,7 @@ server.listen(0, common.mustCall(() => { assert.strictEqual(headers['content-type'], 'text/html'); assert.strictEqual(headers['x-push-data'], 'pushed by server'); })); + stream.on('aborted', common.mustNotCall()); })); let data = '';