http2: fix premature destroy

Check stream._writableState.finished instead of stream.writable
as the latter can lead to premature calls to destroy and dropped
writes on busy processes.

PR-URL: https://github.com/nodejs/node/pull/21051
Fixes: https://github.com/nodejs/node/issues/20750
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
Anatoli Papirovski 2018-05-31 10:39:19 +02:00
parent d52878137d
commit 7b6c4283d2
No known key found for this signature in database
GPG Key ID: 614E2E1ABEB4B2C0

View File

@ -1896,7 +1896,7 @@ class Http2Stream extends Duplex {
}
// TODO(mcollina): remove usage of _*State properties
if (!this.writable) {
if (this._writableState.finished) {
if (!this.readable && this.closed) {
this.destroy();
return;