[whatwg/streams] writeSync function on WritableStreamDefaultWriter to avoid unnecessary heap allocations from Promises returned by write (Issue #1276)

I have an xlsx export process where many writes occur. The exports previously used nodejs's `Writable` the `write` method is synchronous. I converted the streaming over to `WritableStream`. This resulted in a `FATAL ERROR: Reached heap limit Allocation failed`.

Since Promises create heap allocations & apps that use many fire & forget writes to a `WritableStreamDefaultWriter` do not benefit from Promises, it would be more memory efficient to have a synchronous function, such as `writeSync`.

One could await the promises or write to a buffer & queue the writes, but that would complicate & slow down the program. With nodejs's `Writable`, the program can be synchronous. Is this use case something to be considered for Web API streams?

-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/streams/issues/1276
You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/streams/issues/1276@github.com>

Received on Friday, 21 April 2023 05:06:42 UTC