Skip to content
This repository has been archived by the owner on Aug 29, 2021. It is now read-only.

Non-cyclic modules are not waited for #146

Closed
Jamesernator opened this issue Oct 16, 2020 · 1 comment · Fixed by #153
Closed

Non-cyclic modules are not waited for #146

Jamesernator opened this issue Oct 16, 2020 · 1 comment · Fixed by #153

Comments

@Jamesernator
Copy link

Jamesernator commented Oct 16, 2020

In InnerModuleEvaluation Step 1. we have:

1. If module is not a Cyclic Module Record, then
  a. Perform ? module.Evaluate().
  b. Return index.

However as per the changes to Abstract Module Record, .Evaluate() always returns a promise. Previously this step would've thrown the resulting error, but now it simply returns a promise which may reject. As such we need to handle rejections.

This will affect JSON modules which are not cyclic module records:

// works even if "./config.json" has a parsing error
import config from "./config.json" assert { type: "json" };

console.log(config);
@Jamesernator Jamesernator changed the title Non-cyclic module errors are ignored Non-cyclic modules are not waited for Oct 16, 2020
@Jamesernator
Copy link
Author

Realised that the implication is larger than just errors, basically the result of .Evaluate() is not awaited at all. This means if it takes a long time to resolve a cyclic module might execute before .Evaluate() is even finished. As such the value might not even be ready.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant