From e74e4f24dc7dc27ddbda98b6d2317febe2c02df3 Mon Sep 17 00:00:00 2001 From: Kenji Okimoto Date: Fri, 26 Oct 2018 17:27:06 +0900 Subject: [PATCH 1/2] Add null check Sometimes this `cb` is null. --- lib/_stream_writable.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/_stream_writable.js b/lib/_stream_writable.js index 3bad957912b323..9cfb20776cd82a 100644 --- a/lib/_stream_writable.js +++ b/lib/_stream_writable.js @@ -477,7 +477,7 @@ function afterWrite(stream, state, finished, cb) { if (!finished) onwriteDrain(stream, state); state.pendingcb--; - cb(); + cb && cb(); finishMaybe(stream, state); } From 486fbb404eb3fdf4f9bc547ce66406017979263f Mon Sep 17 00:00:00 2001 From: Kenji Okimoto Date: Tue, 30 Oct 2018 10:05:20 +0900 Subject: [PATCH 2/2] Fix style according to suggestion by @devsnek --- lib/_stream_writable.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/_stream_writable.js b/lib/_stream_writable.js index 9cfb20776cd82a..0096aa27a6f4c8 100644 --- a/lib/_stream_writable.js +++ b/lib/_stream_writable.js @@ -477,7 +477,8 @@ function afterWrite(stream, state, finished, cb) { if (!finished) onwriteDrain(stream, state); state.pendingcb--; - cb && cb(); + if (cb) + cb(); finishMaybe(stream, state); }