Add Promise Hooks API with Promise continuation tracking
Maintainers usually reply within 5 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 25/100
Research direction
Read the referenced quickjs-ng PR #1033 and issue #1740 to understand the proposed API and missing continuation events. Then trace Promise reaction jobs and async/await resumptions in QuickJS’s C implementation; the issue does not name source files or tests. Done means providing the hooks API and emitting before/after events consistently for then(), catch(), finally(), and resumed await continuations.
Written by the indexing model from the issue text.
Description
Description
I would like to request the addition of a Promise Hooks API to QuickJS, similar to the implementation introduced in quickjs-ng.
The implementation in quickjs-ng provides embedders with a way to track Promise lifecycles and execution, following the V8 PromiseHook API model.
Reference:
Motivation
Promise execution tracking is useful for embedders that need to implement async context propagation, execution tracking, or Node.js-compatible APIs such as async_hooks.
In particular, being able to observe Promise creation and execution boundaries allows embedders to associate asynchronous operations with their corresponding execution contexts.
Additional Requirement: Promise Continuation Hooks
In addition to porting the Promise Hooks implementation from quickjs-ng, I would like to request that the behavior of JS_PROMISE_HOOK_BEFORE and JS_PROMISE_HOOK_AFTER be considered for Promise continuations.
As discussed in quickjs-ng issue #1740, these hooks are currently not emitted when normal Promise reaction jobs are executed.
For example:
const promise = Promise.resolve();
promise.then(() => {
console.log("continuation");
});
When the Promise reaction job is executed, JS_PROMISE_HOOK_BEFORE and JS_PROMISE_HOOK_AFTER should be emitted around the execution of the continuation.
The same consideration should apply to continuations resumed after await, as well as then(), catch(), and finally().
Expected Behavior
I would like to see:
- A Promise Hooks API equivalent to the implementation in quickjs-ng PR #1033.
JS_PROMISE_HOOK_BEFOREandJS_PROMISE_HOOK_AFTERevents for normal Promise continuations.- Consistent hook behavior for Promise reactions and async/await resumptions.
The goal is to provide embedders with sufficient information to track Promise execution and correctly propagate asynchronous execution contexts.
Thank you for considering this request.
- Dominant language
- C
- Stars
- 11.1k
- Forks
- 1.2k
- PR merge metrics
- No merged PRs in 30d
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from bellard/quickjs
-
Difficulty 1/5 Under an hour Newbie friendliness 75/100
Maintainers usually reply within 5 days
-
RegExp: patterns with more than 255 capture groups fail with "too many captures"Possibly taken @andreasrosdal claimed this 3 days ago. Open
Difficulty 4/5 3-5 days Newbie friendliness 25/100
bellard/quickjs#624 · 1 comment ·
Maintainers usually reply within 5 days
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
bellard/quickjs#620 · 1 comment ·
Maintainers usually reply within 5 days
-
(comment on #611) `function g(a, d = (a = 10)) { return a; }` returns the argument instead of 10Open
Difficulty 4/5 3-5 days Newbie friendliness 30/100
Maintainers usually reply within 5 days
-
Difficulty 4/5 3-5 days Newbie friendliness 30/100
Maintainers usually reply within 5 days
Similar issues
-
documentation good first issue help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
JulianKemmerer/PipelineC#409 ·
-
Linux build fails without libspeechd-dev, which INSTALL.md doesn't list and CMake reports as foundOpen
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
-
needs-playtest slice
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Life-Framework/Life-Framework#4861 ·
Maintainers usually reply within 1 day