Skip to content

Promise and Job Queue API Completion#750

Closed
buke wants to merge 5 commits into
mainfrom
feat/promise-pr4-job-queue
Closed

Promise and Job Queue API Completion#750
buke wants to merge 5 commits into
mainfrom
feat/promise-pr4-job-queue

Conversation

@buke
Copy link
Copy Markdown
Owner

@buke buke commented May 23, 2026

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.

buke added 5 commits May 22, 2026 22:03
- 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
@buke buke closed this May 23, 2026
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

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.

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.

1 participant