diff --git a/source b/source index c50fd94f57e..5d53e5da021 100644 --- a/source +++ b/source @@ -86253,11 +86253,20 @@ interface NavigatorOnLine { script">module scripts; or null. In the former two cases, it represents a parsed script; null represents a failure parsing.
-A JavaScript value, which has meaning only if the record is null.
A JavaScript value representing an error that will prevent evaluation from succeeding. It + will be re-thrown by any attempts to run the script.
+ +There are two main categories of such errors: errors parsing the script's source + text, in which case the script's record will + be null; or more general errors in dependencies of a module script. This + distinction is used by the algorithm for finding the first parse error.
+ +Since this exception value is provided by the JavaScript specification, we know + that it is never null, so we use null to signal that no error has occurred.
+We say that a module script is
- errored if either its record is null, or its
- record's [[Status]] field has the value "errored
".
When a module script is - errored, we say that its error is either - its parse error, when its record is null, or its record's [[ErrorCompletion]] field's [[Value]] field, - otherwise.
- -To set the pre-instantiation - error of a module script script:
- -Let moduleRecord be script's record.
If moduleRecord is not null, set moduleRecord.[[HostDefined]] to - undefined.
Set script's record to - null.
Set script's parse error to error.
We say that a module script has instantiated if its record is not null, and its record's [[Status]] field is either "instantiated
" or "evaluated
".
An environment is an object that identifies the settings of a @@ -86781,13 +86755,6 @@ interface NavigatorOnLine { module script">fetching a single module script asynchronously completes with result:
-If result is null, is - errored, or has instantiated, - asynchronously complete this algorithm with result, and abort these steps.
Assert: result's record's
- [[Status]] is "uninstantiated
".
If the top-level module fetch flag is set, fetch the descendants of and instantiate result given destination and visited set. Otherwise, @@ -86898,9 +86865,8 @@ interface NavigatorOnLine { success).
If module script is - errored or has instantiated, - asynchronously complete this algorithm with module script, and abort these +
If module script's record is null, + then asynchronously complete this algorithm with module script and abort these steps.
Let record be module script's NavigatorOnLine {
These invocations of the internal module script graph fetching procedure should
be performed in parallel to each other. Wait for all invocations of the internal module script graph fetching procedure
- to asynchronously complete, and let results be a list of the results,
- corresponding to the same order they appeared in urls. Then, for each result of results: If result is null, asynchronously complete this algorithm with null, aborting
- these steps. If result is errored,
- then set the pre-instantiation
- error for module script to result's error. Asynchronously complete this algorithm with
- module script, aborting these steps. It is important to wait for all invocations to complete, and then iterate the results in
- order, so that any fetching or pre-instantiation errors are deterministically surfaced to the
- developer. Otherwise, a module script graph with multiple errors would surface a
- nondeterministically chosen error, making debugging quite difficult. As an unobservable optimization, implementations can quit early if an invocation returns
- null or an errored module
- script, and all previous invocations have completed already. However, this is optimizing
- for the rare failure case, so likely not worth the trouble. If any of the invocations of the internal module script graph fetching procedure
+ asynchronously complete with null, asynchronously complete this algorithm with null, aborting
+ these steps. If we've reached this point, all of the internal module script graph fetching
- procedure invocations have asynchronously completed, with module scripts that are not errored. Asynchronously complete this algorithm
- with module script. Otherwise, wait until all of the internal module script graph fetching procedure
+ invocations have asynchronously completed. Asynchronously complete this algorithm with
+ module script.
-
-
-
If result is null or is - errored, then asynchronously complete this algorithm with result.
+If result is null, then asynchronously complete this algorithm with + result.
-In this case, there was an error fetching the descendants, or one of them - failed to parse, or was previously marked as errored. We will not attempt to instantiate.
+In this case, there was an error fetching one or more of the descendants. We + will not attempt to instantiate.
Let record be result's record.
Let parse error be the result of finding the first parse error + given result.
If parse error is not null, then set result's error to parse error.
Perform record.Instantiate().
+Otherwise:
+ +Let record be result's record.
Perform record.Instantiate().
-This step will recursively call Instantiate - on all of the module's uninstantiated dependencies.
+This step will recursively call Instantiate + on all of the module's uninstantiated dependencies.
-If this throws an exception, ignore it for now; it is stored as result's error, and will be reported when we run result.
+If this throws an exception, set result's error to that exception.
+Asynchronously complete this algorithm with result.
To find the first parse error given a root + moduleScript and an optional discoveredSet:
+ +Let moduleMap be moduleScript's settings object's + module map.
If discoveredSet was not given, let it be an empty set.
Append moduleScript to + discoveredSet.
If moduleScript's record is null, + then return moduleScript's error.
+ +It's important that we check if moduleScript's record is null, and not simply check that + moduleScript's error is non-null. This + ensures we only catch errors from parsing moduleScript, and not instantiation errors + or errors from parsing its dependencies that were stored in the error field for later re-throwing.
+Let childSpecifiers be the value of moduleScript's record's [[RequestedModules]] internal slot.
Let childURLs be the list obtained by calling resolve a + module specifier once for each item of childSpecifiers, + given moduleScript and that item. (None of these will ever fail, as otherwise + moduleScript would have been marked as itself having a parse error.)
Let childModules be the list obtained by getting each value in moduleMap whose key is given by an + item of childURLs.
For each childModule of + childModules:
+ +Assert: childModule is a module script (i.e., it is not "fetching
" or null); by now all module
+ scripts in the graph rooted at moduleScript will have successfully been
+ fetched.
If discoveredSet already contains + childModule, continue.
Let childParseError be the result of finding the first parse + error given childModule and discoveredSet.
If childParseError is not null, return childParseError.
Return null.
To create a classic script, given a @@ -87060,10 +87070,10 @@ interface NavigatorOnLine {
If result is a List of errors, then set script's parse error to result[0].
Otherwise, set script's record to - result.
Return script.
If result is a List of errors, then:
Set script's parse error to +
Set script's error to result[0].
Return script.
Let error be a new TypeError
exception.
Set script's parse error - to error.
Set script's error to + error.
Return script.
Set script's record to result.
Set script's error to null.
Set script's base URL to baseURL.
Let evaluationStatus be null.
If script's parse error is not +
If script's error is not null, then set evaluationStatus to Completion { [[Type]]: throw, [[Value]]: - script's parse error, [[Target]]: - empty }.
Otherwise, set evaluationStatus to NavigatorOnLine {
Let evaluationStatus be null. If script is errored,
- then set evaluationStatus to Completion { [[Type]]: throw, [[Value]]:
- script's error, [[Target]]:
- empty }. If script's error is not
+ null, then set evaluationStatus to Completion { [[Type]]: throw, [[Value]]:
+ script's error, [[Target]]: empty
+ }. Otherwise: Assert: resolved module script is a module script (i.e., is not
null or " Assert: resolved module script is not errored. Assert: resolved module script's record is not null. Return resolved module script's record.fetching
").