From 359a6590b0023b7703f56f20044b19e25f28d7bb 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 e73624739a6b62..22a2deee83fba9 100644 --- a/doc/api/stream.md +++ b/doc/api/stream.md @@ -580,6 +580,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`