diff --git a/lib/internal/stream_base_commons.js b/lib/internal/stream_base_commons.js index 55b9c3d4bb03e0..233741285d2c72 100644 --- a/lib/internal/stream_base_commons.js +++ b/lib/internal/stream_base_commons.js @@ -204,7 +204,9 @@ function onStreamRead(arrayBuffer) { } if (nread !== UV_EOF) { - return stream.destroy(errnoException(nread, 'read')); + // #34375 CallJSOnreadMethod expects the return value to be a buffer. + stream.destroy(errnoException(nread, 'read')); + return; } // Defer this until we actually emit end @@ -221,8 +223,11 @@ function onStreamRead(arrayBuffer) { // test-https-truncate test. if (handle.readStop) { const err = handle.readStop(); - if (err) - return stream.destroy(errnoException(err, 'read')); + if (err) { + // #34375 CallJSOnreadMethod expects the return value to be a buffer. + stream.destroy(errnoException(err, 'read')); + return; + } } // Push a null to signal the end of data.