-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix module script error handling, again
Recent investigation determined more problems with the module script graph fetching algorithms with regard to error handling. Essentially, they were not robust to network races during fetching. Certain errors would be propagated nondeterministically; worse, Evaluate() could be called on modules with errored dependencies, due to another module script graph interleaving its instantiation between a graph's instantiation and evaluation. This revision avoids all these problems. The strategy is essentially: * Do not record instantiation errors of dependencies. This is mostly a feature of a corresponding revision to the JavaScript specification; we just no longer look for such errors. Instead, we call Instantiate(), which now does a from-scratch re-instantiation attempt, finding the appropriate error each time. * Do not record parse errors of dependencies. Instead, traverse the graph right before instantiation to deterministically find the first parse error. To implement this strategy, the error fields of the script struct were converted to a single error field, whose purpose is to store an error that is to be re-thrown during instantiation. (An alternate implementation would have been to find another way of passing the error from "prepare a script" and its associated script-fetching algorithms, to "execute a script block" and its associated script-running algorithms. But the script struct was a convenient place to keep this.) Note that with this strategy we no longer inspect the [[Status]] or [[ErrorCompletion]] fields of JavaScript's Source Text Module Records; instead, we can simply call Instantiate() or Evaluate() and deal with any thrown errors. This is a much nicer encapsulation boundary.
- Loading branch information
Showing
1 changed file
with
119 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters