-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Null script block in "fetch an inline module script graph" is unreachable #9864
Comments
Helps with #9864. (But does not fix the other problem identified there yet.)
The problem is not the load event being delayed. "mark as ready" is still called, and that clears the delaying load event flag. The problem is that "mark as ready" is called (in step 32 > "module" > 3.1) before "steps to run when the result is ready" are set up (in step 33.2.3 or 33.3.3 or 33.4.2). This means that no "error" event will fire for these parse errors. There are two ways to fix this:
I'll work on a spec change to do (2). |
Continuing from web-platform-tests/wpt#45660 (comment). Let's read the HTML and ES specs further to find out how synchronous or asynchronous we should be for:
Our main focus is on no-import module scripts. Obviously if a module script has imports, then evaluating the script and signaling evaluation errors or load events are forced to be async, delayed by at least a task. But it's not so simple for the no-import case, as we'll see. We're also focused mainly on module scripts with First, if there are parse errors, then we don't involve the ES spec. HTML gets to decide how to handle these.
OK. So let's say we have no parse errors. Then, during script preparation, HTML synchronously calls into ECMAScript's Evaluate(), which in turn ends up in InnerModuleEvaluation. This has a special case for zero-import modules, which synchronously calls ExecuteModule(), i.e. runs the code. But if there are imports, then of course we have to wait to fetch them via the host. After evaluating, the ES spec generates a promise. That promise is given to the host, and has to take at least a microtask to settle. So the host can only react to the execution after a microtask. So this means that if there are evaluation errors (e.g. So this means our choices for no-import module scripts are restricted to the following:
Given this information, I guess the cleanest thing is to delay "execute the script element" by a task. This will match WebKit / Chromium behavior, and ensure that everything is always delayed by a task: no matter whether it's a parse error vs. evaluation error vs. successful evaluation, or whether it's no-import vs. some-imports. I'll work on updating the spec and tests. |
Thanks you for that comment, that's extremely helpful and clear. I think I agree with your conclusion. Adding @smaug---- @ljharb @littledan @domfarolino for visibility. |
You mean because ES currently generates a promise to hand to the host, putting the scheduling (from the host perspective) at a microtask delay at baseline?
Just for clarity, is this a single task period, when considering everything from script evaluation to error signals observation? Or is this a single task after the post-evaluation microtask is run? Basically I'm asking if from the time to execution --> error signal observation is (a) 1 microtask + 1 full task, or (b) just 1 full task (with no browser implementing the microtask thing). Eh, hopefully those questions make sense! |
I agree with @domenic’s thorough analysis. |
Yes.
I'm not able to distinguish with black-box testing, and I didn't dig into the code to find out. |
whatwg/html#9864 discusses the issue. whatwg/html#10272 matches what is tested here.
…er, a=testonly Automatic update from web-platform-tests Test inserted async script execution order whatwg/html#9864 discusses the issue. whatwg/html#10272 matches what is tested here. -- wpt-commits: 5adce6fa88ba7bcb5c119d62736fb30cf1273306 wpt-pr: 45660
…er, a=testonly Automatic update from web-platform-tests Test inserted async script execution order whatwg/html#9864 discusses the issue. whatwg/html#10272 matches what is tested here. -- wpt-commits: 5adce6fa88ba7bcb5c119d62736fb30cf1273306 wpt-pr: 45660
What is the issue with the HTML Standard?
In fetch an inline module script graph, there is a null check for
script
which synchronously callsonComplete
withnull
:However, in create a JavaScript module script, none of the return statements return a null script:
Additionally, calling
onComplete
synchronously is incorrect, as it will run the callback before the ready callbacks are setup later in prepare the script element, causing the load event to be delayed forever.The text was updated successfully, but these errors were encountered: