-
Notifications
You must be signed in to change notification settings - Fork 161
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
Test or specification problem with TransformStream readable.cancel and calling controller.error #1296
Comments
That's interesting. This test passes in the reference implementation and in Deno's implementation. Is it possible your implementation diverges from the spec elsewhere? |
I'll investigate which exact code path is taken here in the reference implementation next week! |
Faced something similar in the nodejs implementation too have described it here nodejs/node#50126 (comment) it weird that the for the reference implementation and deno the promises for start and cancel resolve in the following order
and hence the same error isnt faced, I thought it must be because of some of the promise transformations maybe? but cant put my finger on it |
My observation on Gecko side matches what @debadree25 saw: the start promise in SetUpWritableStreamDefaultController is created first but the cancel promise in TransformStreamDefaultSourceCancelAlgorithm responds first. I'm unsure why is that 🤔 |
My hunch is maybe we missed some promise transformations but I tried applying all the promise transformation methods used in the spec like uponPromise, etc. but didn't make a difference 😅 |
Our investigation so far found that:
But I haven't found why the start promise listener still runs earlier than the cancel promise listener in the reference implementation. |
Hmm, logging transformerDict.cancel at
function invokeTheCallbackFunction(reason) {
const thisArg = utils.tryWrapperForImpl(this);
let callResult;
try {
callResult = Reflect.apply(value, thisArg, [reason]);
callResult = new Promise(resolve => resolve(callResult));
return callResult;
} catch (err) {
return Promise.reject(err);
}
} And the returned promise is unresolved, which means listening on this promise takes an extra round. That's webidl2js layer, not sure why it's implemented like this, I should check the spec and also try updating webidl2js to v17 (#1297, but it didn't change the behavior). |
@saschanaz The WebIDL specification (as currently written) requires this. In step 13 of invoke a callback function type, the call result is converted to an IDL value. This must be an IDL Promise, whose conversion is defined as:
It would be nice if this could use the |
I tried updating the usage of Promise.resolve() -> new Promise(r => r(value)) for |
What is the issue with the Streams Standard?
There is a test for TansformStream cancel (#1283) called
https://github.com/web-platform-tests/wpt/blob/4ab37a2aa733a03162ce2d5e3782d5da7940c330/streams/transform-streams/cancel.any.js#L79
I think that test is wrong or the specification for
TransformStreamDefaultSourceCancelAlgorithm
is wrong.We can observe in that test that the promise for the cancel callback is going to be fulfilled. So we are in
The next step is
I think this step is not going to be taken, because the [[state]] is "erroring". As set by
controller.error
, via WritableStreamStartErroring.The whole path is
So this could be fixed by changing the condition to
Or of course adjusting the test to except a different promise resolution.
@lucacasonato @MattiasBuelens
The text was updated successfully, but these errors were encountered: