镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Implement private async-context call ABI #373

Closed

Description

@chrisbbreuer

Parent: #134

Implements the coherent async-context call boundary shared by the pinned Home and Bun inventories. This is a child of the private ABI coverage work tracked by #140, #163, and #164.

Scope

  • AsyncContextFrame__withAsyncContextIfNeeded
  • Bun__JSValue__isAsyncContextFrame
  • Bun__JSValue__call

Bake__getAsyncLocalStorage is intentionally out of scope: upstream exposes a separately stored Bake/dev-server ALS instance, not the currently active async-context value captured by these wrappers.

Acceptance

  • Add a realm-local active async-context value as a precise traced and relocated GC root.
  • Represent an AsyncContextFrame as a branded, non-callable object with strong callback and captured-context edges.
  • Return callbacks unchanged when no context is active and avoid double-wrapping existing frames.
  • Invoke plain callbacks and wrapped callbacks with exact argument ordering and global-this fallback for an empty receiver.
  • Install the captured context for the dynamic extent of the call and restore the prior context before normal return or exception publication.
  • Reject invalid/foreign handles without crossing VM ownership boundaries.
  • Cover brand, capture, nested restoration, throw restoration, GC retention/relocation, and compiled Home/Bun consumer signatures.
  • Refresh generated ABI inventories and coverage documentation, batch Debug/ReleaseSafe verification, then close this issue only after the pushed main commit is green.

Activity

  1. chrisbbreuer commented on Jul 20, 2026

    @chrisbbreuer
    MemberAuthor

    Implemented and pushed directly to main in df79596 (feat(abi): implement async context calls (#373)).

    Delivered:

    • AsyncContextFrame__withAsyncContextIfNeeded, Bun__JSValue__isAsyncContextFrame, and Bun__JSValue__call
    • realm-local precisely traced/relocated active async-context root
    • branded null-prototype non-callable frame with strong callback/context edges
    • exact inactive identity, no double wrapping, encoded argument order, empty-receiver global fallback, same-VM validation, and restoration before normal return or throw publication
    • insertion barriers plus a temporary root for the displaced context across callback-triggered GC
    • compiled Home and Bun consumer evidence and refreshed pinned inventories/docs

    Verification (Debug and ReleaseSafe):

    • focused async-context engine tests: 3/3 passed, 0 leaked
    • relocation-focused engine tests: 25/25 passed, 0 leaked
    • Home private consumer: 352/352 linked and runtime matrix passed
    • Bun private C-API extension consumer passed
    • C/API inventory audit passed

    Coverage is now Home 365/471 (106 pending) and Bun 357/461 (104 pending). Bake__getAsyncLocalStorage remains intentionally separate because upstream stores a distinct Bake/dev-server ALS instance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions