diff --git a/lib/internal/http2/compat.js b/lib/internal/http2/compat.js index 4622d97614a1bb..145e77410494b6 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]); } }