Skip to content

Commit f5e9bb1

Browse files
Trottrvagg
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 ed714a2 commit f5e9bb1

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

lib/internal/http2/compat.js

+6-8
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)