Commit c4dd7cb
fix(bun): Consume fetch response body to prevent memory leak
Bun's fetch implementation retains the backing ArrayBuffer of unconsumed
response bodies indefinitely. This causes a memory leak when sending
many Sentry envelopes, as each response's ArrayBuffer accumulates in
memory.
This applies the same fix that was made for the Cloudflare transport in
getsentry#18545 — consuming the response body with response.text() after
extracting the needed headers.
In production, this leak manifests as ~8KB ArrayBuffers accumulating at
~8/sec (one per envelope), leading to OOM kills after ~5 hours on
containers with 4GB memory limits.1 parent 8808ea1 commit c4dd7cb
1 file changed
Lines changed: 12 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
18 | 29 | | |
19 | 30 | | |
20 | 31 | | |
| |||
0 commit comments