-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Description
What is the issue with the HTML Standard?
Step 14. Fetch a single imported module script ...
onSingleFetchComplete given moduleScript is the following algorithm:
...
3. Otherwise, if moduleScript's parse error is not null, then:
Here only the parse error is checked, shouldn't the moduleScript's error to rethrow should be checked as well?
Image the following test,
// parse_error.js
!@#$
// import_parse_error.mjs
import "./parse_error.js";
// parent_import_parse_error.mjs
import "./import_parse_error.mjs";
// index.html
<script type="module" src="./import_parse_error.mjs"></script>
<script type="module" src="./parent_import_parse_error.mjs"></script>
when fetching import_parse_error.mjs,
the spec starts from fetch an external module script graph,
then the module script is fetched, and it will be stored in the module map in fetch a single module script, Step 13, processResponseConsumeBody, step 8.
Set moduleMap[(url, moduleType)] to moduleScript, and run onComplete given moduleScript.
Then continue to fetch the descendants of and link a module script to call LoadRequestedModules
And then HostLoadImportedModule will be called to fetch parse_error.js
, since it has a parse error, so the error will be passed to FinishLoadingImportedModule in Step 14, onSingleFetchComplete, Step 3
This will go back to rejected handler of LoadRequestedModules for import_parse_error.mjs, fetch the descendants of and link a module script, step 7.`
7. Upon rejection of loadingPromise,
1. If state.[[ErrorToRethrow]] is not null, set moduleScript's error to rethrow to state.[[ErrorToRethrow]]
As of for now, import_parse_error.mjs is stored in the module map, and it has an error to rethrow
Now the 2nd top-level script, parent_import_parse_error.mjs is being processed,
When the HostLoadImportedModule with import_parse_error.mjs is called
the module script exists in module map, however, as mentioned in the beginning,
the algorithm only checks if it has a parse error, but doesn't check if it has an error to rethrow
Is this intentional ? So import_parse_error.mjs will be fetched again anyway, or this is a bug in the spec?
Thanks
CCing @nicolo-ribaudo