-
-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
range error thrown when using createWriteStream() #48
Comments
In Line 46 in c179012
The However, I'm not sure if that will completely solve your problem. You are trying to create a buffer for 9 GB, however:
|
I get this with slightly more than 1GB (using this library transitively through 'download'):
|
The problem is the following: buffers with Node.js have a max size of 4GB, and strings of ~5e8 characters (which is ~500MB if using only ASCII characters, but fewer with UTF-8 characters). The limits are available at The reason this fails is because Node.js cannot represent a file with >4GB in a You can reproduce the problem like this (if your OS has head -c 10000000000 /dev/urandom > big Then: import { createReadStream } from 'node:fs'
import { getStreamAsBuffer } from 'get-stream'
await getStreamAsBuffer(createReadStream('./big')) Which results in:
It is generally a bad practice to buffer that much memory, as opposed to stream it, as it makes the process use a large amount of the machine's memory. Also, in some cases, V8 crashes when too much memory is used. Also, the But for importantly, this is not a problem with |
Hi, I'm running a file queue service that uses
'child_process'.createWriteStream()
.For files much larger than the JS callstack this library consistently throws the error
Is there a way to prevent this error from throwing?
The text was updated successfully, but these errors were encountered: