Promise and Job Queue API Completion#750
Closed
buke wants to merge 5 commits into
Closed
Conversation
- add runtime job queue APIs for pending checks, pending context lookup, and executing one pending job - add context promise primitives including PromiseCapability, NewPromiseCapability, NewSettledPromise, and EnqueueJob alias - add focused runtime/context tests for normal and fail-closed paths while keeping full coverage green
- add runtime APIs for promise hook and host promise rejection tracker with owner/liveness fail-closed behavior - bridge quickjs promise hook and host rejection tracker callbacks from C into Go runtime dispatch - add runtime tests for callback lifecycle, fail-closed behavior, and dispatch guard paths while preserving full coverage
- align Value.PromiseState with quickjs-ng semantics by returning PromiseNotAPromise for non-promise values - add Value.PromiseResult to expose native JS_PromiseResult behavior for fulfilled, rejected, pending, and non-promise values - update context/value tests to cover the new semantics and PromiseResult API while keeping full coverage at 100%
- add Runtime.DrainPendingJobs(max) to drain pending jobs with optional execution limit - propagate job execution errors with context exception fallback semantics - add runtime tests for limit, full drain, error path, and fail-closed behavior while preserving full coverage
- add Context.EnqueueNativeJob to enqueue callable jobs through QuickJS native JS_EnqueueJob - introduce bridge helper EnqueueCallableJob with callable validation and JS call dispatch in native job callback - add context promise primitive tests for enqueue success, thrown job errors, and fail-closed guards while keeping full coverage
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces several enhancements to promise handling and job scheduling. Key additions include EnqueueNativeJob for native job queueing, NewPromiseCapability and NewSettledPromise for finer promise control, and runtime-level hooks for promise lifecycle events and host rejection tracking. It also refines PromiseState to distinguish non-promise values and adds PromiseResult to retrieve the result of a promise. I have no feedback to provide.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR section closes PR4 with two focused batches:
Batch A adds a bounded/unbounded runtime drain helper for pending jobs.
Batch B adds a minimal native job enqueue API for callable JS values, backed by JS_EnqueueJob.