-
Notifications
You must be signed in to change notification settings - Fork 16
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
Throwing a thenable object in locks.requests callback will implicitly invoke its .then()
#77
Comments
I suspect you’ve found a Chromium bug. Neither Web IDL nor the internal ECMA-262 promise operations that Web IDL delegates to would access properties / invoke methods of a rejected Promise’s “reason” value — as you said, only fulfilling should lead to “unpacking”. I don’t think Web Locks is supposed to be doing anything unique in this regard. |
Agreed, looks like a Chrome bug. Can you file one via new.crbug.com ? |
@bathos Thanks for your clarification. I am investigating chromium source code which might relates to the issue, will update on the above ticket if I found something suspicious, thanks guys :) |
Thanks. I made a note in the crbug about where to look in the code. I'll leave this open for a bit; we should have a WPT for this. |
This comment has been minimized.
This comment has been minimized.
Hi @inexorabletash, Sorry if I didn't express well in the above comment. When I think the easiest approach to solve this is that we shouldn't return the thenable value in I also left a comment (with the proposed WPT testcase for this) on crbug as well. |
Hey, let's keep the Chromium discussions on the Chromium bug. It's not a high priority issue so hasn't been given a lot of attention. |
Can this be closed then? |
I think I left this open since we should add a WPT for this case. |
May I know what's the expected behavior of the to-do WPT from your perspective?
However, this issue need to be fixed in |
That test makes sense to me. |
Chromium CL up at https://chromium-review.googlesource.com/4064307 that includes a WPT |
An edge case first reported on github[1] - the result from the lock acquisition callback should be the resolution of the call's promise. If the result is itself a promise (or a thenable - i.e. has a then() method), then it should be "unpacked" per normal promise handling. This works! Also, if the result is an "abrupt completion" (i.e the callback throws), that means the resolution should be an exception. So far, so good! But if that exception is a thenable, it should not be "unpacked" per normal promise handling. But this is what was happening in Chrome! The spec is fine here, it was just an implementation bug. Fix the implementation and add a WPT to cover this case. [1] w3c/web-locks#77 Bug: 1250253 Change-Id: Ib38cd1ff48d5f25e1939f50e614ce623c2d10a35
The test case should be upstreamed soon, so closing this. |
An edge case first reported on github[1] - the result from the lock acquisition callback should be the resolution of the call's promise. If the result is itself a promise (or a thenable - i.e. has a then() method), then it should be "unpacked" per normal promise handling. This works! Also, if the result is an "abrupt completion" (i.e the callback throws), that means the resolution should be an exception. So far, so good! But if that exception is a thenable, it should not be "unpacked" per normal promise handling. But this is what was happening in Chrome! The spec is fine here, it was just an implementation bug. Fix the implementation and add a WPT to cover this case. [1] w3c/web-locks#77 Bug: 1250253 Change-Id: Ib38cd1ff48d5f25e1939f50e614ce623c2d10a35 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4064307 Commit-Queue: Joshua Bell <jsbell@chromium.org> Reviewed-by: Ayu Ishii <ayui@chromium.org> Cr-Commit-Position: refs/heads/main@{#1077650}
An edge case first reported on github[1] - the result from the lock acquisition callback should be the resolution of the call's promise. If the result is itself a promise (or a thenable - i.e. has a then() method), then it should be "unpacked" per normal promise handling. This works! Also, if the result is an "abrupt completion" (i.e the callback throws), that means the resolution should be an exception. So far, so good! But if that exception is a thenable, it should not be "unpacked" per normal promise handling. But this is what was happening in Chrome! The spec is fine here, it was just an implementation bug. Fix the implementation and add a WPT to cover this case. [1] w3c/web-locks#77 Bug: 1250253 Change-Id: Ib38cd1ff48d5f25e1939f50e614ce623c2d10a35 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4064307 Commit-Queue: Joshua Bell <jsbell@chromium.org> Reviewed-by: Ayu Ishii <ayui@chromium.org> Cr-Commit-Position: refs/heads/main@{#1077650}
An edge case first reported on github[1] - the result from the lock acquisition callback should be the resolution of the call's promise. If the result is itself a promise (or a thenable - i.e. has a then() method), then it should be "unpacked" per normal promise handling. This works! Also, if the result is an "abrupt completion" (i.e the callback throws), that means the resolution should be an exception. So far, so good! But if that exception is a thenable, it should not be "unpacked" per normal promise handling. But this is what was happening in Chrome! The spec is fine here, it was just an implementation bug. Fix the implementation and add a WPT to cover this case. [1] w3c/web-locks#77 Bug: 1250253 Change-Id: Ib38cd1ff48d5f25e1939f50e614ce623c2d10a35 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4064307 Commit-Queue: Joshua Bell <jsbell@chromium.org> Reviewed-by: Ayu Ishii <ayui@chromium.org> Cr-Commit-Position: refs/heads/main@{#1077650}
…ck shouldn't invoke it, a=testonly Automatic update from web-platform-tests Web Locks: Throwing a thenable in callback shouldn't invoke it An edge case first reported on github[1] - the result from the lock acquisition callback should be the resolution of the call's promise. If the result is itself a promise (or a thenable - i.e. has a then() method), then it should be "unpacked" per normal promise handling. This works! Also, if the result is an "abrupt completion" (i.e the callback throws), that means the resolution should be an exception. So far, so good! But if that exception is a thenable, it should not be "unpacked" per normal promise handling. But this is what was happening in Chrome! The spec is fine here, it was just an implementation bug. Fix the implementation and add a WPT to cover this case. [1] w3c/web-locks#77 Bug: 1250253 Change-Id: Ib38cd1ff48d5f25e1939f50e614ce623c2d10a35 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4064307 Commit-Queue: Joshua Bell <jsbell@chromium.org> Reviewed-by: Ayu Ishii <ayui@chromium.org> Cr-Commit-Position: refs/heads/main@{#1077650} -- wpt-commits: 3428426669666600429687c1cfb708cefd8cc79b wpt-pr: 37259
An edge case first reported on github[1] - the result from the lock acquisition callback should be the resolution of the call's promise. If the result is itself a promise (or a thenable - i.e. has a then() method), then it should be "unpacked" per normal promise handling. This works! Also, if the result is an "abrupt completion" (i.e the callback throws), that means the resolution should be an exception. So far, so good! But if that exception is a thenable, it should not be "unpacked" per normal promise handling. But this is what was happening in Chrome! The spec is fine here, it was just an implementation bug. Fix the implementation and add a WPT to cover this case. [1] w3c/web-locks#77 Bug: 1250253 Change-Id: Ib38cd1ff48d5f25e1939f50e614ce623c2d10a35 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4064307 Commit-Queue: Joshua Bell <jsbell@chromium.org> Reviewed-by: Ayu Ishii <ayui@chromium.org> Cr-Commit-Position: refs/heads/main@{#1077650}
…ck shouldn't invoke it, a=testonly Automatic update from web-platform-tests Web Locks: Throwing a thenable in callback shouldn't invoke it An edge case first reported on github[1] - the result from the lock acquisition callback should be the resolution of the call's promise. If the result is itself a promise (or a thenable - i.e. has a then() method), then it should be "unpacked" per normal promise handling. This works! Also, if the result is an "abrupt completion" (i.e the callback throws), that means the resolution should be an exception. So far, so good! But if that exception is a thenable, it should not be "unpacked" per normal promise handling. But this is what was happening in Chrome! The spec is fine here, it was just an implementation bug. Fix the implementation and add a WPT to cover this case. [1] w3c/web-locks#77 Bug: 1250253 Change-Id: Ib38cd1ff48d5f25e1939f50e614ce623c2d10a35 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4064307 Commit-Queue: Joshua Bell <jsbell@chromium.org> Reviewed-by: Ayu Ishii <ayui@chromium.org> Cr-Commit-Position: refs/heads/main@{#1077650} -- wpt-commits: 3428426669666600429687c1cfb708cefd8cc79b wpt-pr: 37259
Hi @inexorabletash , I have a question about throwing a "thenable" object (or returning a rejected promise with thenable object) in the web-locks api callback. "thenable" means that the object defines its .then() method.
Consider the following code,
I am wondering is this an expected behavior?
Didn't find any spec mentioning this behavior. One might related is that if we return(resolve) a "thenable" object inside promise chain, it will unpack it by calling
.then
. It will call all.then
's until it gets raw value.I'm using Chrome 91.0.4472.106 (Official Build) (64-bit) on ubuntu 18.04.
The text was updated successfully, but these errors were encountered: