2021/11/5 Workers Runtime Release Notes

Changes this week:

  • Upgrade to V8 9.6. This adds support for WebAssembly reference types. See V8 release v9.6 · V8 for more details.
  • Streams: When using the BYOB reader, the ArrayBuffer of the provided TypedArray should be detached, per the Streams spec. Because Workers was not previously enforcing that rule, and changing to comply with the spec could breaking existing code, a new compatibility flag, streams_byob_reader_detaches_buffer, has been introduced that will be enabled by default on 2021-11-10. User code should never try to re-use an ArrayBuffer that has been passed in to a BYOB readers read() method. The more recently added extension method readAtLeast() will always detach the ArrayBuffer and is unaffected by the compatibility flag setting.
3 Likes

I have a follow up question related to BYOB, which is the minimum size of the data returned. Has this been improved lately, meaning, that the caller can request a minimum payload size to be retrieved?

Hi @scooletz, apologies for the slow reply.

Has this been improved lately, meaning, that the caller can request a minimum payload size to be retrieved?

Yes. We implemented a non-standard readAtLeast() method. From prior release notes:

  • Added non-standard ReadableStreamBYOBReader method .readAtLeast(size, buffer) that can be used to return a buffer with at least size bytes. The buffer parameter must be an ArrayBufferView . Behavior is identical to .read() except that at least size bytes are read, only returning fewer if EOF is encountered. One final call to .readAtLeast() is still needed to get back a done = true value.

It appears that we don’t yet document this, which is unfortunate. I have filed an issue for that here.

2 Likes

How I missed that! Thank you for sharing awesome news! My own buffers are eager to consume it! :tada: