Skip to content

Fix TLA: module should wait for its async dependencies #2488

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ktzhang
Copy link

@ktzhang ktzhang commented May 11, 2024

Reopening #2402 since the case is still valid.
Addresses: #2473

Here's the test results without the changes applied:
image

If module b depends on a but a has already been "seen"(postOrderExec-ed), then b won't wait for a's execution if a is an async module.

During bug fixing, I also found test case `./test/system-core.js/Core API/Loading Cases/Top-level await/Should may be incorrect test case(which means equivalent module logic doesn't hold same semantic with ESM). I also updated that expected behaviour.

case 1 show the BUG this PR wants to resolve.

case 2 show the test case problem as described above.

Copy link

File size impact

Merging kz/top-level-await-fix into main will impact 3 files in 2 groups.

browser (2/2)
File raw gzip brotli Event
dist/s.min.js +194 (8,165) +67 (3,215) +62 (2,924) modified
dist/system.min.js +83 (12,403) +18 (4,772) +21 (4,304) modified
Total size impact +277 (20,568) +85 (7,987) +83 (7,228)
node (1/1)
File raw gzip brotli Event
dist/system-node.cjs +69 (522,118) +20 (126,174) +52 (84,932) modified
Total size impact +69 (522,118) +20 (126,174) +52 (84,932)
extras (0/8)

No impact on files in extras group.

Generated by file size impact during size-impact#9041229355

Copy link
Member

@guybedford guybedford left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you so much for looking into this. Because this is a very complex algorithm, I think just having one test case is not enough to prove we aren't introducing other regressions.

For better testing I would advise looking at cases from the TLA fuzzer at https://github.com/evanw/tla-fuzzer, and trying to incorporate some more and show that this overall improves conformance over degraging it.

Comment on lines -316 to +321
if (!process.env.SYSTEM_PRODUCTION) triggerOnload(loader, load, load.er, true);
triggerOnload(loader, load, load.er, true);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The onload event is only for the non-production build.


return doExec();
if (depLoadPromises) {
return load.E = Promise.all(depLoadPromises).then(doExec).finally(function() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is quite a big algorithmic change, that will likely have repercussions. I think to be comfortable making these kinds of algorithmic changes it would help to see much more test cases being checked.

@guybedford
Copy link
Member

I've also pushed a change to main to fix the broken CI.

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

Successfully merging this pull request may close these issues.

2 participants