Skip to content

Commit 09056fd

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 e9a8f0c commit 09056fd

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
@@ -202,7 +202,9 @@ function onStreamRead(arrayBuffer) {
202202
}
203203

204204
if (nread !== UV_EOF) {
205-
return stream.destroy(errnoException(nread, 'read'));
205+
// #34375 CallJSOnreadMethod expects the return value to be a buffer.
206+
stream.destroy(errnoException(nread, 'read'));
207+
return;
206208
}
207209

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

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

0 commit comments

Comments
 (0)