★ wanayoo — archive 1999 https://github.com/nodejs/node/commit/8df4a168b3Nouvelle recherche | Portail wanayoo
Skip to content
Permalink
Browse files

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>
  • Loading branch information...
Trott authored and codebytere committed Nov 16, 2018
1 parent 4b82aa8 commit 8df4a168b3a86b1b9d3c245a7715b48234898b8c
Showing with 6 additions and 8 deletions.
  1. +6 −8 lib/internal/http2/compat.js
@@ -1,5 +1,6 @@
'use strict';

const assert = require('assert');
const Stream = require('stream');
const Readable = Stream.Readable;
const binding = process.binding('http2');
@@ -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]);
}
}

0 comments on commit 8df4a16

Please sign in to comment.
You can’t perform that action at this time.