Skip to content

Commit 454db9b

Browse 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 <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]>
1 parent ff4eeae commit 454db9b

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

lib/internal/http2/compat.js

Lines 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)