don't use TextDecoder
+ arrayBuffer()
in blob.text()
#42265
Labels
buffer
Issues and PRs related to the buffer subsystem.
...Use TextDecoderStream Instead. ( or stream-consumers.text() )
Here is the problem:
node/lib/internal/blob.js
Lines 312 to 313 in 6b004f1
Version
17.5
Platform
mac
Subsystem
No response
What steps will reproduce the bug?
How often does it reproduce? Is there a required condition?
every single time
What is the expected behavior?
to read a 500mb + blob using
blob.text()
A solution i'm using in fetch-blob is using the streaming approach
What do you see instead?
Additional information
it's a disadvantage to use ArrayBuffer/TextEncoder in your .text() method to read it as a string.
At the time when you read the blob as a text it will use 3x memory (the size of the blob, the size of the arrayBuffer and the size of the string) quite a large memory spike at this point, there is no chance for v8 to do a GC
there is also a problem in v8 that you can't create strings with more than 500 MiB
however it's fine to concat the strings using
str += 'foo'
to avoid this problem. (as strings can just be references point to other multiple strings with a size & offset)See more info here: https://stackoverflow.com/questions/61271613/chrome-filereader-api-event-target-result
The text was updated successfully, but these errors were encountered: