-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
"Entry" concept is broken while executing enqueued jobs #1426
Comments
As discussed in #473, starting especially from around #473 (comment), the definition of incumbent introduced in #401 falls down in certain important cases. In order to fix this, we introduce several new concepts, which takes care of these trickier examples. These examples are now included in the spec, and spell out exactly how exactly incumbent settings object calculation works in increasingly-complex scenarios. The new algorithms "prepare to run a callback" and "clean up after running a callback" will be used by Web IDL, similarly to how it already uses "prepare to run script" and "clean up after running script." Another notable change is that EnqueueJob now correctly tracks the necessary goings-on in order to make the incumbent settings object work correctly when promises are used to schedule callbacks. However, we noticed that it does not correctly track the entry settings object; the previous text, introduced in #1091, incorrectly referred to job.[[Realm]], which does not exist. The correct fix is unfortunately not obvious. So we add a warning there for now, with #1426 tracking further work.
Hahahaha look at what I found from 2014: domenic/promises-unwrapping#108 |
@bzbarsky this suddenly came up as indirectly blocking me on #3117. It looks like reviewing earlier threads the following would be the most consistent:
Does this seem right to you, and/or match with Firefox (especially after recent work to move promises into the JS engine)? This is going to suck to write tests for. Right now as a spec strategy I am contemplating just listing these two cases in the HTML spec's EnqueueJob. Maybe we can do better ES integration later if they ever want to work with us on jobs. |
I'll try to dig through the Firefox code here, but it certainly won't happen until Monday. Maybe @tschneidereit recalls offhand what we ended up implementing... |
I think that matches exactly what we implemented. See this comment and this one for PromiseReactionJob and this one for PromiseResolveThenableJob. |
V8 used to use the microtask context when it runs EnqueueJob step 2. > Let job settings be some appropriate environment settings object. https://html.spec.whatwg.org/multipage/webappapis.html#enqueuejob(queuename,-job,-arguments) However, it's being updated to use the handler's context. whatwg/html#1426 (comment) Change-Id: I24840a28ef2c903539fe4ace74ae59da290f5109 Reviewed-on: https://chromium-review.googlesource.com/c/1465902 Reviewed-by: Toon Verwaest <verwaest@chromium.org> Commit-Queue: Taiju Tsuiki <tzik@chromium.org> Cr-Commit-Position: refs/heads/master@{#59870}
I tried to spec out #1426 (comment) but I realized that
is not quite true, because the settings object chosen here is also used for determining whether we can run script. This runs into the thorny issues around promises in navigated-away-from documents. I guess there is no harm in running |
#1189 ties up almost all the loose ends around defining entry and incumbent, as part of a series of work (most of which can be found by following links from #473). However, in the course of working on it, @bzbarsky and I discovered that figuring out how to preserve the entry concept correctly while executing EnqueueJob (i.e., promise jobs) is tricky. It looks like doing so would either require some strange contortions, or some more invasive changes to JS's promise mechanisms. See #1189 (comment) onward for details. In the meantime, #1189 adds a warning:
The text was updated successfully, but these errors were encountered: