Closed cjpillsbury closed 5 months ago
Approved, but feels like we should update the documentation in this PR too? At the very least make sure it's included in the list of options.
Approved, but feels like we should update the documentation in this PR too? At the very least make sure it's included in the list of options.
Yup good call! Will do before merging.
Went ahead and spruced up some other docs bits and bobs that I noticed.
This PR adds an "opt in" (via config options) fallback for cases where the (newer)
ReadableStream
File/Blob API fails (e.g. due to https://bugs.webkit.org/show_bug.cgi?id=272600). When "opted in", upchunk will revert to reading the file into memory, which is less ideal in general but may be preferred to simply failing and notifying (via an error event) about the failure. This allows developers to decide how they want to handle these cases.The fallback can be enabled by setting the
useFileSliceFallback
options flag totrue
.fixes #134
NOTE: The reason this isn't being turned on by default relates to the primary known error that necessitates the fallback. WebKit (including Safari) has a bug where, if a file is 4GB or larger, it will error when attempting to read the file using the
File
'sReadableStream
. However, we migrated to usingReadableStream
instead of loading the file into memory in v3.x specifically because of concerns/complaints that this could be very bad for JS thread heap memory consumption, sometimes resulting in crashes for memory-scarce environments or excessively large files. Since 4GB isn't an excessively small file (😅), and this is the case we are primarily accounting for, we didn't want to suddenly and automatically put developers back into that "greedy memory" usage scenario, but, since this issue has yet to be resolved in WebKit, we want to provide some answer to those cases beyond notifying an error (which we now do, too).