Re: [whatwg/streams] Warn about async processing of written/transformed chunks (PR #1239)

I think this is good enough in that respect because in the Chromium implementation of the Web Serial API the copying of bytes from the chunk happens on the same platform thread where JavaScript is executed so it isn't really "in parallel" but still raises the same concerns about asynchronous processing since JavaScript execution can be interleaved with the copying. This is behavior that a JavaScript implementation of an underlying sink could also encounter.

A couple remaining concerns,

1. Does recommending that the underlying sink make a copy of the data help when the data could also have been modified between the call to `WritableStreamDefaultWriter.write()` and when `write()` is called on the underlying sink? Asking callers to wait for the `Promise` returned by `write()` to resolve before reusing the buffer solves the problem whether or not the chunk was queued.
2. Ignoring (1), transferring the chunk would fix the problem but also is a breaking API change so it's not something a library could easily do to fix the problem after the fact.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/streams/pull/1239#issuecomment-1209883948
You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/streams/pull/1239/c1209883948@github.com>

Received on Tuesday, 9 August 2022 20:51:58 UTC