Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 8df4a16

Browse filesBrowse files
Trottcodebytere
authored andcommitted
http2: replace unreachable error with assertion
"That particular `emit('error', ...)` is largely defensively coded and should not ever actually happen." Sounds like an assertion rather than an error event. The code in question has no test coverage because it is believed to be unreachable. Fixes: #20673 PR-URL: #24407 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
1 parent 4b82aa8 commit 8df4a16
Copy full SHA for 8df4a16

File tree

Expand file treeCollapse file tree

1 file changed

+6
-8
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+6
-8
lines changed
Open diff view settings
Collapse file

‎lib/internal/http2/compat.js‎

Copy file name to clipboardExpand all lines: lib/internal/http2/compat.js
+6-8Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
'use strict';
22

3+
const assert = require('assert');
34
const Stream = require('stream');
45
const Readable = Stream.Readable;
56
const binding = process.binding('http2');
@@ -331,15 +332,12 @@ class Http2ServerRequest extends Readable {
331332

332333
_read(nread) {
333334
const state = this[kState];
334-
if (!state.closed) {
335-
if (!state.didRead) {
336-
state.didRead = true;
337-
this[kStream].on('data', onStreamData);
338-
} else {
339-
process.nextTick(resumeStream, this[kStream]);
340-
}
335+
assert(!state.closed);
336+
if (!state.didRead) {
337+
state.didRead = true;
338+
this[kStream].on('data', onStreamData);
341339
} else {
342-
this.emit('error', new ERR_HTTP2_INVALID_STREAM());
340+
process.nextTick(resumeStream, this[kStream]);
343341
}
344342
}
345343

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.