GeezerVison is showing github.com — http2: allow streams to complete gracefully after goaway · nodejs/node@1bfcf81
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: lib/internal/http2/core.js +5-2Lines changed: 5 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -2358,8 +2358,11 @@ class Http2Stream extends Duplex { | 2358 | 2358 | // This notifies the session that this stream has been destroyed and | 2359 | 2359 | // gives the session the opportunity to clean itself up. The session | 2360 | 2360 | // will destroy if it has been closed and there are no other open or | 2361 | | - // pending streams. | 2362 | | - session[kMaybeDestroy](); | | 2361 | + // pending streams. Delay with setImmediate so we don't do it on the | | 2362 | + // nghttp2 stack. | | 2363 | + setImmediate(() => { | | 2364 | + session[kMaybeDestroy](); | | 2365 | + }); | 2363 | 2366 | callback(err); | 2364 | 2367 | } | 2365 | 2368 | // The Http2Stream can be destroyed if it has closed and if the readable | |
Collapse file Copy file name to clipboardExpand all lines: lib/internal/js_stream_socket.js +4-1Lines changed: 4 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -179,10 +179,13 @@ class JSStreamSocket extends Socket { | 179 | 179 | // anything. doClose will call finishWrite with ECANCELED for us shortly. | 180 | 180 | this[kCurrentWriteRequest] = req; // Store req, for doClose to cancel | 181 | 181 | return 0; | | 182 | + } else if (this._handle === null) { | | 183 | + // If this._handle is already null, there is nothing left to do with a | | 184 | + // pending write request, so we discard it. | | 185 | + return 0; | 182 | 186 | } | 183 | 187 |
| 184 | 188 | const handle = this._handle; | 185 | | - assert(handle !== null); | 186 | 189 |
| 187 | 190 | const self = this; | 188 | 191 |
| |
Collapse file Copy file name to clipboardExpand all lines: test/parallel/test-h2-large-header-cause-client-to-hangup.js +8-2Lines changed: 8 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -7,7 +7,7 @@ const http2 = require('http2'); | 7 | 7 | const assert = require('assert'); | 8 | 8 | const { | 9 | 9 | DEFAULT_SETTINGS_MAX_HEADER_LIST_SIZE, | 10 | | - NGHTTP2_CANCEL, | | 10 | + NGHTTP2_FRAME_SIZE_ERROR, | 11 | 11 | } = http2.constants; | 12 | 12 |
| 13 | 13 | const headerSize = DEFAULT_SETTINGS_MAX_HEADER_LIST_SIZE; | @@ -28,11 +28,17 @@ server.listen(0, common.mustCall(() => { | 28 | 28 | function send() { | 29 | 29 | const stream = clientSession.request({ ':path': '/' }); | 30 | 30 | stream.on('close', common.mustCall(() => { | 31 | | - assert.strictEqual(stream.rstCode, NGHTTP2_CANCEL); | | 31 | + assert.strictEqual(stream.rstCode, NGHTTP2_FRAME_SIZE_ERROR); | 32 | 32 | clearTimeout(timer); | 33 | 33 | server.close(); | 34 | 34 | })); | 35 | 35 |
| | 36 | + stream.on('error', common.expectsError({ | | 37 | + code: 'ERR_HTTP2_STREAM_ERROR', | | 38 | + name: 'Error', | | 39 | + message: 'Stream closed with error code NGHTTP2_FRAME_SIZE_ERROR' | | 40 | + })); | | 41 | + | 36 | 42 | stream.end(); | 37 | 43 | } | 38 | 44 | })); |
Collapse file Copy file name to clipboardExpand all lines: test/parallel/test-http2-exceeds-server-trailer-size.js +6-2Lines changed: 6 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -43,9 +43,13 @@ server.listen(0, () => { | 43 | 43 | const clientStream = clientSession.request(); | 44 | 44 |
| 45 | 45 | clientStream.on('close', common.mustCall()); | 46 | | - // These events mustn't be called once the frame size error is from the server | | 46 | + clientStream.on('error', common.expectsError({ | | 47 | + code: 'ERR_HTTP2_STREAM_ERROR', | | 48 | + name: 'Error', | | 49 | + message: 'Stream closed with error code NGHTTP2_FRAME_SIZE_ERROR' | | 50 | + })); | | 51 | + // This event mustn't be called once the frame size error is from the server | 47 | 52 | clientStream.on('frameError', common.mustNotCall()); | 48 | | - clientStream.on('error', common.mustNotCall()); | 49 | 53 |
| 50 | 54 | clientStream.end(); | 51 | 55 | }); |
Collapse file Copy file name to clipboardExpand all lines: test/parallel/test-http2-trailers-after-session-close.js -3Lines changed: 0 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 3 | 3 | // Fixes: https://github.com/nodejs/node/issues/42713 | 4 | 4 | const common = require('../common'); | 5 | 5 | if (!common.hasCrypto) { | 6 | | - // Remove require('assert').fail when issue is fixed and test | 7 | | - // is moved out of the known_issues directory. | 8 | | - require('assert').fail('missing crypto'); | 9 | 6 | common.skip('missing crypto'); | 10 | 7 | } | 11 | 8 | const assert = require('assert'); | |
|