- From: wattroll <notifications@github.com>
- Date: Fri, 22 Dec 2023 03:30:13 -0800
- To: whatwg/fetch <fetch@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <whatwg/fetch/issues/1592/1867577139@github.com>
@matthieusieben > your approach is great but it does load everything in memory Good point. Everything in this case would be at most `maxByteLength` bytes will get buffered into the `tee()`-ed stream during `request.clone().body?.pipeTo(...)` and be held until the `await request.formData()` completes. Buffering up to the limit could be acceptable for the use-cases where the limit is low, but not for larger limits with final consumers that stream the chunks efficiently to somewhere. I used that approach for a login adapter that accepts email/password form which I wanted to limit very tightly, so that my auth service isn't exposed to OOM with large and slow payloads. I also expected that Deno's `Body#formData` would buffer the whole body in memory either way. I think it should be possible to sink the cloned request into byte counter and application sink in parallel, so that when the byte counter tips over it cancels the other one. I haven't tried that yet. I also don't know whether any server-side runtimes feature disk-backed `Body#formData()`. Per my understanding `formData` has to receive the body fully before returning (in order to provide the `Blob#size` property for each of the `File` in the form). -- Reply to this email directly or view it on GitHub: https://github.com/whatwg/fetch/issues/1592#issuecomment-1867577139 You are receiving this because you are subscribed to this thread. Message ID: <whatwg/fetch/issues/1592/1867577139@github.com>
Received on Friday, 22 December 2023 11:30:19 UTC