Skip to content

Commit 566a694

Browse files
committed
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: nodejs#20673 PR-URL: nodejs#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 7ba83e8 commit 566a694

1 file changed

Lines changed: 6 additions & 8 deletions

File tree

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 = internalBinding('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)