Skip to content

Commit c0be31f

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 614298d commit c0be31f

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
@@ -208,7 +208,9 @@ function onStreamRead(arrayBuffer) {
208208
}
209209

210210
if (nread !== UV_EOF) {
211-
return stream.destroy(errnoException(nread, 'read'));
211+
// #34375 CallJSOnreadMethod expects the return value to be a buffer.
212+
stream.destroy(errnoException(nread, 'read'));
213+
return;
212214
}
213215

214216
// Defer this until we actually emit end
@@ -225,8 +227,11 @@ function onStreamRead(arrayBuffer) {
225227
// test-https-truncate test.
226228
if (handle.readStop) {
227229
const err = handle.readStop();
228-
if (err)
229-
return stream.destroy(errnoException(err, 'read'));
230+
if (err) {
231+
// #34375 CallJSOnreadMethod expects the return value to be a buffer.
232+
stream.destroy(errnoException(err, 'read'));
233+
return;
234+
}
230235
}
231236

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

0 commit comments

Comments
 (0)