You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Apparently the node implementation of Buffer.copy changed somewhere between v18.12 and v18.20, which leads to all copy calls with sourceStart > buffer.length throwing an Error.
This affects the fs.createReadStream method when called with a start parameter:
Example:
Replace the code inside of createReadstream.ts in the demo folder to:
Run with ts-node demo/createReadStream.ts (or transpile and run with node) results in:
ts-node demo/createReadStream.ts
data # Hello World
RangeError [ERR_OUT_OF_RANGE]: The value of "sourceStart" is out of range. It must be >= 0 && <= 13. Received 65536
at new NodeError (node:internal/errors:405:5)
at _copy (node:buffer:227:13)
at Buffer.copy (node:buffer:821:12)
at Node.read (/home/breitdo/dev/git/test/memfs/src/node.ts:195:14)
at File.read (/home/breitdo/dev/git/test/memfs/src/node.ts:542:29)
at Volume.readBase (/home/breitdo/dev/git/test/memfs/src/volume.ts:861:17)
at Immediate.<anonymous> (/home/breitdo/dev/git/test/memfs/src/volume.ts:899:28)
at processImmediate (node:internal/timers:476:21) {
code: 'ERR_OUT_OF_RANGE'
}
Apparently the node implementation of
Buffer.copy
changed somewhere between v18.12 and v18.20, which leads to all copy calls withsourceStart > buffer.length
throwing an Error.This affects the
fs.createReadStream
method when called with a start parameter:Example:
Replace the code inside of
createReadstream.ts
in the demo folder to:Run with
ts-node demo/createReadStream.ts
(or transpile and run with node) results in:Issue:
The culprit is in
src/node.ts:194
:Possible fix:
Inserting another check after line 185 fixes this issue:
The text was updated successfully, but these errors were encountered: