From 617f2dc0cf260db502edded88c26dede0a1c321e Mon Sep 17 00:00:00 2001 From: Robert Nagy Date: Fri, 25 Sep 2020 18:40:01 +0200 Subject: [PATCH] stream: writableNeedDrain Don't write to a stream which already has a full buffer. Fixes: https://github.com/nodejs/node/issues/35341 PR-URL: https://github.com/nodejs/node/pull/35348 Reviewed-By: Matteo Collina Reviewed-By: Luigi Pinca Reviewed-By: Benjamin Gruenbaum --- doc/api/stream.md | 9 +++++++ lib/_http_outgoing.js | 5 ++++ lib/internal/streams/duplex.js | 2 ++ lib/internal/streams/pipeline.js | 4 +++ lib/internal/streams/readable.js | 7 ++++- lib/internal/streams/writable.js | 8 ++++++ test/parallel/test-stream-pipe-needDrain.js | 29 +++++++++++++++++++++ 7 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 test/parallel/test-stream-pipe-needDrain.js diff --git a/doc/api/stream.md b/doc/api/stream.md index 81e2a7247ee..baa72e565e8 100644 --- a/doc/api/stream.md +++ b/doc/api/stream.md @@ -570,6 +570,15 @@ This property contains the number of bytes (or objects) in the queue ready to be written. The value provides introspection data regarding the status of the `highWaterMark`. +##### `writable.writableNeedDrain` + + +* {boolean} + +Is `true` if the stream's buffer has been full and stream will emit `'drain'`. + ##### `writable.writableObjectMode`