Hacker News new | ask | show | jobs
by goldenarm 88 days ago
The lack of backpressure handling nor promise api for postMessage is also quite annoying, I had many OOMs because of it.
1 comments

It's not ideal, the api is kind of low-yet-high-level and that brings some complications.

Move backpressure handling onto the task producer and use a SharedArrayBuffer between the producer and worker, where the worker atomically updates a work-count or current work item ID in that SharedArrayBuffer that the producer can read (atomically) to determine how far along the worker has gotten.