tc39/proposal-top-level-await

Error persistence in cycles

guybedford opened this issue · 1 comments

Consider the simple cycle A <-> B, where B is async and where A also imports the synchronous module C after B.

If, while B is executing we get a sync failure on C, this causes the error of C to populate the error along the whole stack which includes B thus setting B.[[EvaluationError]] to the C error (along with A and C).

But B is still executing, and can later reject, which currently would cause the evaluation error on the B module record to be replaced by the B failure error, instead of the previously set C failure error.

Should we:

  1. Be overwriting the [[EvaluationError]] on B with its async rejection, or
  2. Should we allow the [[EvaluationError]] of C to persist on B?

In these types of cases, typically sticking to the most well-defined behaviour as in (2) probably makes the most sense I think?

(2) is also effectively what the current ES module specification does in that any import to B at any later point in the application will get the error from C reported.

Closing as (2) above was merged in #114.