Skip to content

Commit b1890e0

Browse files
robeyaddaleax
authored andcommitted
net: don't return the stream object from onStreamRead
CallJSOnreadMethod expects the return value to be undefined or a new buffer, so make sure to return nothing, even when an error causes us to destroy the stream. Fixes: #34346 PR-URL: #34375 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Robert Nagy <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Matteo Collina <[email protected]>
1 parent 276e298 commit b1890e0

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

lib/internal/stream_base_commons.js

+8-3
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,9 @@ function onStreamRead(arrayBuffer) {
204204
}
205205

206206
if (nread !== UV_EOF) {
207-
return stream.destroy(errnoException(nread, 'read'));
207+
// #34375 CallJSOnreadMethod expects the return value to be a buffer.
208+
stream.destroy(errnoException(nread, 'read'));
209+
return;
208210
}
209211

210212
// Defer this until we actually emit end
@@ -221,8 +223,11 @@ function onStreamRead(arrayBuffer) {
221223
// test-https-truncate test.
222224
if (handle.readStop) {
223225
const err = handle.readStop();
224-
if (err)
225-
return stream.destroy(errnoException(err, 'read'));
226+
if (err) {
227+
// #34375 CallJSOnreadMethod expects the return value to be a buffer.
228+
stream.destroy(errnoException(err, 'read'));
229+
return;
230+
}
226231
}
227232

228233
// Push a null to signal the end of data.

0 commit comments

Comments
 (0)