Skip to content

Reject a module's own capability before its async parents - #1647

Open
andreasrosdal wants to merge 2 commits into
quickjs-ng:masterfrom
nordstjernen-web:fix-async-module-rejection-order
Open

Reject a module's own capability before its async parents#1647
andreasrosdal wants to merge 2 commits into
quickjs-ng:masterfrom
nordstjernen-web:fix-async-module-rejection-order

Conversation

@andreasrosdal

Copy link
Copy Markdown
Contributor

AsyncModuleExecutionRejected rejects the module's own [[TopLevelCapability]] first and only then recurses into [[AsyncParentModules]], so the top-level promises of a failing graph settle leaf-to-root:

9.  If module.[[TopLevelCapability]] is not empty, then
    b. Perform ! Call(module.[[TopLevelCapability]].[[Reject]], undefined, « error »).
10. For each Cyclic Module Record m of module.[[AsyncParentModules]], do
    a. Perform AsyncModuleExecutionRejected(m, error).

js_async_module_execution_rejected() runs those two steps the other way round, so an importer of the failing module is rejected before the module itself. Swap them.

Fixes test262/test/language/module-code/top-level-await/rejection-order.js, which is listed in test262_errors.txt; the entry is dropped.

🤖 Generated with Claude Code

https://claude.ai/code/session_014mv33YvfHz7t9mmkituBnn


Generated by Claude Code

claude added 2 commits August 6, 2026 17:30
AsyncModuleExecutionRejected rejects the module's own [[TopLevelCapability]]
first and only then recurses into [[AsyncParentModules]], so the top-level
promises of a failing graph settle leaf-to-root:

    9. If module.[[TopLevelCapability]] is not empty, then
       b. Perform ! Call(module.[[TopLevelCapability]].[[Reject]], ...).
    10. For each Cyclic Module Record m of module.[[AsyncParentModules]], do
       a. Perform AsyncModuleExecutionRejected(m, error).

js_async_module_execution_rejected() runs those two steps the other way
round, so an importer of the failing module is rejected before the module
itself. Swap them.

Fixes test262 language/module-code/top-level-await/rejection-order.js, which
is listed in test262_errors.txt; drop the entry.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014mv33YvfHz7t9mmkituBnn
A three module chain, each link imported in its own right so that each one
has a top level capability, makes the order observable: rejecting the
module's own capability before recursing into its async parents settles the
chain leaf first, and doing it the other way around settles it in reverse.

Also checks that every module in the chain reports the identical error
object, that re-importing a failed module keeps reporting it, and that two
independent ancestors of one failing leaf are both notified.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K6eRbuuuCujKgQkrHgvMrc
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