Skip to content

feat: Run Promise hooks around promise continuation jobs - #1801

Open
nabetti1720 wants to merge 1 commit into
quickjs-ng:masterfrom
nabetti1720:feat/promise-before-after-hook
Open

nabetti1720 wants to merge 1 commit into
quickjs-ng:masterfrom
nabetti1720:feat/promise-before-after-hook

Conversation

@nabetti1720

@nabetti1720 nabetti1720 commented Oct 3, 2026 •

Copy link
Copy Markdown

Closes #1740

Description of changes

This change emits JS_PROMISE_HOOK_BEFORE and JS_PROMISE_HOOK_AFTER around Promise reaction handler execution, passing the continuation Promise to both hooks.

When a Promise hook is installed, await handling creates a throwaway Promise capability for the continuation and associates it with the awaited Promise. When no hook is installed, await retains the existing allocation-free path.

Compatibility limitation: To preserve this optimization, the continuation Promise is created only if a hook is installed when the await reaction is scheduled. If a hook is installed afterward, BEFORE and AFTER still fire when the reaction runs, but their Promise argument may be undefined.

Tests cover hook invocation for .then() and await, including continuation Promise identity and its parent Promise.

Validation: cmake --build build --target api-test && ./build/api-test

This branch has not been deployed

No deployments
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.

PromiseHook does not fire BEFORE/AFTER for Promise continuations

1 participant