-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Confusing "async" completion of script fetching #3746
Comments
In the example, I expect the module script is evaluated in the "deferred" timing, and thus the result is (2), no matter whether I feel (2) is more consistent, in that module scripts are always asynchronous and non-parser-blocking. |
Thanks. I might have gotten lost in the spec; would you be able to check my reasoning on which part of the spec calls "execute a script block" in this case? My reading is that we reach the
and step 25 says
So "the script is ready" immediately (synchronously). Did I miss something? |
Or, sorry, you are correct. I missed the parser-inserted check in the first clause of Step 26. Still, (2) is the current behavior of Chromium, because for module scripts Chromium considers the script is ready always asynchronously. |
Both Chrome and Safari agree that module scripts with no imports run asynchronously, per the semi-ambiguous language in the HTML Standard discussed in whatwg/html#3746, despite the script being "ready" immediately. Firefox seems to implement the spec correctly, regarding the "readiness" being synchronous, however with 2/3 implementations *not* implementing the spec in this regard, and an open spec issue in this area, I find it unlikely that Chromium's will change its behavior (for compat). I'll recommend on the spec issue that we change the spec to match Safari and Chrome, and land this test asserting the majority behavior. R=domenic@chromium.org Bug: N/A Change-Id: Ibeac277ab357b62e7d0a5e4afb5f95818a2d4005
Both Chrome and Safari agree that module scripts with no imports run asynchronously, per the semi-ambiguous language in the HTML Standard discussed in whatwg/html#3746, despite the script being "ready" immediately. Firefox seems to implement the spec correctly, regarding the "readiness" being synchronous, however with 2/3 implementations *not* implementing the spec in this regard, and an open spec issue in this area, I find it unlikely that Chromium's will change its behavior (for compat). I'll recommend on the spec issue that we change the spec to match Safari and Chrome, and land this test asserting the majority behavior. R=domenic@chromium.org Bug: N/A Change-Id: Ibeac277ab357b62e7d0a5e4afb5f95818a2d4005
Both Chrome and Safari agree that module scripts with no imports run asynchronously, per the semi-ambiguous language in the HTML Standard discussed in whatwg/html#3746, despite the script being "ready" immediately. Firefox seems to implement the spec correctly, regarding the "readiness" being synchronous, however with 2/3 implementations *not* implementing the spec in this regard, and an open spec issue in this area, I find it unlikely that Chromium's will change its behavior (for compat). I'll recommend on the spec issue that we change the spec to match Safari and Chrome, and land this test asserting the majority behavior. R=domenic@chromium.org Bug: N/A Change-Id: Ibeac277ab357b62e7d0a5e4afb5f95818a2d4005 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4371802 Commit-Queue: Dominic Farolino <dom@chromium.org> Reviewed-by: Domenic Denicola <domenic@chromium.org> Cr-Commit-Position: refs/heads/main@{#1126561}
Just for completeness, I added a tentative WPT for this over in web-platform-tests/wpt#39205. |
Both Chrome and Safari agree that module scripts with no imports run asynchronously, per the semi-ambiguous language in the HTML Standard discussed in whatwg/html#3746, despite the script being "ready" immediately. Firefox seems to implement the spec correctly, regarding the "readiness" being synchronous, however with 2/3 implementations *not* implementing the spec in this regard, and an open spec issue in this area, I find it unlikely that Chromium's will change its behavior (for compat). I'll recommend on the spec issue that we change the spec to match Safari and Chrome, and land this test asserting the majority behavior. R=domenic@chromium.org Bug: N/A Change-Id: Ibeac277ab357b62e7d0a5e4afb5f95818a2d4005 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4371802 Commit-Queue: Dominic Farolino <dom@chromium.org> Reviewed-by: Domenic Denicola <domenic@chromium.org> Cr-Commit-Position: refs/heads/main@{#1126561}
Both Chrome and Safari agree that module scripts with no imports run asynchronously, per the semi-ambiguous language in the HTML Standard discussed in whatwg/html#3746, despite the script being "ready" immediately. Firefox seems to implement the spec correctly, regarding the "readiness" being synchronous, however with 2/3 implementations *not* implementing the spec in this regard, and an open spec issue in this area, I find it unlikely that Chromium's will change its behavior (for compat). I'll recommend on the spec issue that we change the spec to match Safari and Chrome, and land this test asserting the majority behavior. R=domenic@chromium.org Bug: N/A Change-Id: Ibeac277ab357b62e7d0a5e4afb5f95818a2d4005 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4371802 Commit-Queue: Dominic Farolino <dom@chromium.org> Reviewed-by: Domenic Denicola <domenic@chromium.org> Cr-Commit-Position: refs/heads/main@{#1126561}
Both Chrome and Safari agree that module scripts with no imports run asynchronously, per the semi-ambiguous language in the HTML Standard discussed in whatwg/html#3746, despite the script being "ready" immediately. Firefox seems to implement the spec correctly, regarding the "readiness" being synchronous, however with 2/3 implementations *not* implementing the spec in this regard, and an open spec issue in this area, I find it unlikely that Chromium's will change its behavior (for compat). I'll recommend on the spec issue that we change the spec to match Safari and Chrome, and land this test asserting the majority behavior. R=domenic@chromium.org Bug: N/A Change-Id: Ibeac277ab357b62e7d0a5e4afb5f95818a2d4005 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4371802 Commit-Queue: Dominic Farolino <dom@chromium.org> Reviewed-by: Domenic Denicola <domenic@chromium.org> Cr-Commit-Position: refs/heads/main@{#1126561}
…-import module script, a=testonly Automatic update from web-platform-tests Script: Add execution timing test for no-import module script Both Chrome and Safari agree that module scripts with no imports run asynchronously, per the semi-ambiguous language in the HTML Standard discussed in whatwg/html#3746, despite the script being "ready" immediately. Firefox seems to implement the spec correctly, regarding the "readiness" being synchronous, however with 2/3 implementations *not* implementing the spec in this regard, and an open spec issue in this area, I find it unlikely that Chromium's will change its behavior (for compat). I'll recommend on the spec issue that we change the spec to match Safari and Chrome, and land this test asserting the majority behavior. R=domenic@chromium.org Bug: N/A Change-Id: Ibeac277ab357b62e7d0a5e4afb5f95818a2d4005 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4371802 Commit-Queue: Dominic Farolino <dom@chromium.org> Reviewed-by: Domenic Denicola <domenic@chromium.org> Cr-Commit-Position: refs/heads/main@{#1126561} -- wpt-commits: f2151fce99621bd8e5526747f3a15d0df9741a38 wpt-pr: 39205
The spec now explicitly does (2), probably since #8253 that made the loading process consistently await the "loadingPromise" returned by ECMA-262's LoadRequestedModules() regardless of the number of dependencies. |
…ive, a=testonly Automatic update from web-platform-tests Mark non-external-noimport as non-tentative See whatwg/html#3746 (comment). Closes whatwg/html#3746. -- wpt-commits: 39ac6ad1cf7e29e07dae7c8ec487f2074bb0600d wpt-pr: 41081
…ive, a=testonly Automatic update from web-platform-tests Mark non-external-noimport as non-tentative See whatwg/html#3746 (comment). Closes whatwg/html#3746. -- wpt-commits: 39ac6ad1cf7e29e07dae7c8ec487f2074bb0600d wpt-pr: 41081 UltraBlame original commit: a2c56c14c2d2bc69eca72b3f74ebcaa6f9d37ac4
…ive, a=testonly Automatic update from web-platform-tests Mark non-external-noimport as non-tentative See whatwg/html#3746 (comment). Closes whatwg/html#3746. -- wpt-commits: 39ac6ad1cf7e29e07dae7c8ec487f2074bb0600d wpt-pr: 41081 UltraBlame original commit: a2c56c14c2d2bc69eca72b3f74ebcaa6f9d37ac4
…ive, a=testonly Automatic update from web-platform-tests Mark non-external-noimport as non-tentative See whatwg/html#3746 (comment). Closes whatwg/html#3746. -- wpt-commits: 39ac6ad1cf7e29e07dae7c8ec487f2074bb0600d wpt-pr: 41081 UltraBlame original commit: a2c56c14c2d2bc69eca72b3f74ebcaa6f9d37ac4
…ive, a=testonly Automatic update from web-platform-tests Mark non-external-noimport as non-tentative See whatwg/html#3746 (comment). Closes whatwg/html#3746. -- wpt-commits: 39ac6ad1cf7e29e07dae7c8ec487f2074bb0600d wpt-pr: 41081
Pointed out by @jonco3.
The script fetching algorithms all use an "asynchronous completion" framework, which is not very well-defined. See whatwg/infra#181.
In particular, several people assume that "async" means "queue a task". But it's quite possible to not end up queuing a task, e.g. if you "fetch the descendants of and instantiate" a module with no descendants. So then the presence of the words "when this asynchronously completes" causes confusion.
The particular case we were concerned with was "prepare a script" step 25 for src-less module scripts, which says
In code, the case in question is a classic inline script that inserts a module inline script:
There are a couple of possible dimensions of consistency here:
Currently the spec picks (1), but in a confusing way because of the use of the word "asynchronously" which causes people to think maybe it's (2).
/cc @whatwg/modules. I'd love folks thoughts on whether (1) or (2) is more natural.
Side note: if we pick (2), then we should remove the "set currentScript to null" logic inside "execute a script block", since currentScript will always be null anyway.
Also, I might have gotten something wrong here, as this is subtle stuff; please feel free to check my logic.
The text was updated successfully, but these errors were encountered: