diff options
author | Rich Trott <rtrott@gmail.com> | 2018-11-16 15:51:07 -0800 |
---|---|---|
committer | Rich Trott <rtrott@gmail.com> | 2018-11-20 15:22:18 -0800 |
commit | 566a694bbc67219d8765921c9b7d494b8a18a50c (patch) | |
tree | fc27daefd6a94ef43bed19667c1c526e701e52e1 /lib/internal/http2/compat.js | |
parent | 7ba83e893e44179abf339c042653334ed71a3f19 (diff) | |
download | android-node-v8-566a694bbc67219d8765921c9b7d494b8a18a50c.tar.gz android-node-v8-566a694bbc67219d8765921c9b7d494b8a18a50c.tar.bz2 android-node-v8-566a694bbc67219d8765921c9b7d494b8a18a50c.zip |
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: https://github.com/nodejs/node/issues/20673
PR-URL: https://github.com/nodejs/node/pull/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>
Diffstat (limited to 'lib/internal/http2/compat.js')
-rw-r--r-- | lib/internal/http2/compat.js | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/lib/internal/http2/compat.js b/lib/internal/http2/compat.js index 4622d97614..145e774104 100644 --- a/lib/internal/http2/compat.js +++ b/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 = internalBinding('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]); } } |