-
Notifications
You must be signed in to change notification settings - Fork 162
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix assertion failure in RespondInternal after transferring array buffer in RespondWithNewView #1174
Conversation
Merge from original repo
Merge from Original Repo
Update forked repo
Good catch! 👍 The reference implementation doesn't correctly implement Could you update the reference implementation to reflect the spec text changes?
When you respond to a BYOB request, we must immediately take back control of the buffer so we can (later on) give it back to the initiating read-into request. If we didn't transfer the buffer immediately, then you could do something like: const view = controller.byobRequest.view;
view[0] = 12;
controller.byobRequest.respondWithNewView(view.subarray(0, 1));
view[0] = 34; // shouldn't be possible! |
Done :) Thank you for the explanation! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
While implementing #1123 in Chrome, I realised that calling
RespondInternal(controller, view.[[viewByteLength]]
after callingTransferArrayBuffer(view.[[ViewedArrayBuffer]])
makes the assertion in RespondInternal(), specificallyAssert: bytesWritten > 0
, fail. This is becauseview.[[viewByteLength]]
becomes 0 after transferring the array buffer.This can either be solved by not using
TransferArrayBuffer()
(which was the case before) or by storing theview.[[viewByteLength]]
first before transferring the buffer. In this PR, I've taken the latter approach.@MattiasBuelens I'm wondering if you have any context on why we changed the standard to use
TransferArrayBuffer()
inRespondWithNewView()
?Preview | Diff