Skip to content

Commit

Permalink
http2: replace unreachable error with assertion
Browse files Browse the repository at this point in the history
"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]>
  • Loading branch information
Trott committed Nov 20, 2018
1 parent 7ba83e8 commit 566a694
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions lib/internal/http2/compat.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use strict';

const assert = require('assert');
const Stream = require('stream');
const Readable = Stream.Readable;
const binding = internalBinding('http2');
Expand Down Expand Up @@ -331,15 +332,12 @@ class Http2ServerRequest extends Readable {

_read(nread) {
const state = this[kState];
if (!state.closed) {
if (!state.didRead) {
state.didRead = true;
this[kStream].on('data', onStreamData);
} else {
process.nextTick(resumeStream, this[kStream]);
}
assert(!state.closed);
if (!state.didRead) {
state.didRead = true;
this[kStream].on('data', onStreamData);
} else {
this.emit('error', new ERR_HTTP2_INVALID_STREAM());
process.nextTick(resumeStream, this[kStream]);
}
}

Expand Down

0 comments on commit 566a694

Please sign in to comment.