Summary
Since 0.24.10, .config({ path }).fetch(...) (stream-to-file mode) writes only the first 8 KB (8192 bytes) of a response when the server does not send a Content-Length header. The rest of the body is silently dropped, producing a truncated/corrupt file. 0.24.9 writes the full file correctly — this is a regression introduced between 0.24.9 and 0.24.10.
Environment
|
|
| react-native-blob-util |
0.24.10 (broken) — 0.24.9 works |
| react-native |
0.85.3 |
| Platform |
Android (confirmed on emulator + physical device, Hermes). iOS not yet verified. |
| Server |
Responds over HTTP/2 with the file bytes but no Content-Length header (chunked/streamed). |
Steps to reproduce
- Have a server endpoint that returns a binary file (e.g. a ~13 KB PDF) without a
Content-Length response header.
- Download it to a file using stream-to-path mode:
const res = await ReactNativeBlobUtil
.config({ path: localFilePath, timeout: 20000 })
.fetch('POST', url, headers, body);
// res.info().status === 200
- Inspect the file on disk.
Expected
The file on disk is the full response body (e.g. 13264 bytes).
Actual
The file on disk is exactly 8192 bytes (the first 8 KB), regardless of the true size. The download reports success (status === 200), so there's no error surfaced — the file is just silently truncated and therefore corrupt. (In our case react-native-pdf then rejects it as "Unsupported URL".)
Key observation — the network read is fine; the file writer is the problem
On the same 0.24.10 build and the same endpoint:
- Reading the response into memory returns the complete body:
const full = res.base64(); // full 13264 bytes ✅
await ReactNativeBlobUtil.fs.writeFile(path, full, 'base64'); // full file ✅
- Streaming the response directly to a file path truncates it:
.config({ path }).fetch(...) // only 8192 bytes on disk ❌
So the bytes are received correctly off the wire — the truncation is in the stream-to-file write path when Content-Length is absent (it appears to stop after the first read buffer / 8 KB chunk
rather than draining the stream to EOF).
Regression range
- 0.24.9 (published 2026-05-19) — writes the full file ✅
- 0.24.10 (published 2026-06-19) — truncates at 8 KB ❌
Downgrading to 0.24.9 fully resolves it. It looks like a change in the native download/stream-write logic (Android) between these two patch releases.
Workaround
Either pin to 0.24.9, or avoid stream-to-path and buffer in memory (res.base64() + is undesirable for large files
Summary
Since 0.24.10,
.config({ path }).fetch(...)(stream-to-file mode) writes only the first 8 KB (8192 bytes) of a response when the server does not send aContent-Lengthheader. The rest of the body is silently dropped, producing a truncated/corrupt file. 0.24.9 writes the full file correctly — this is a regression introduced between 0.24.9 and 0.24.10.Environment
Content-Lengthheader (chunked/streamed).Steps to reproduce
Content-Lengthresponse header.Expected
The file on disk is the full response body (e.g. 13264 bytes).
Actual
The file on disk is exactly 8192 bytes (the first 8 KB), regardless of the true size. The download reports success (
status === 200), so there's no error surfaced — the file is just silently truncated and therefore corrupt. (In our case react-native-pdf then rejects it as "Unsupported URL".)Key observation — the network read is fine; the file writer is the problem
On the same 0.24.10 build and the same endpoint:
So the bytes are received correctly off the wire — the truncation is in the stream-to-file write path when
Content-Lengthis absent (it appears to stop after the first read buffer / 8 KB chunkrather than draining the stream to EOF).
Regression range
Downgrading to 0.24.9 fully resolves it. It looks like a change in the native download/stream-write logic (Android) between these two patch releases.
Workaround
Either pin to
0.24.9, or avoid stream-to-path and buffer in memory (res.base64()+ is undesirable for large files