Skip to content

AsyncContext proposal integration (part 1)#12152

Open
andreubotella wants to merge 2 commits intowhatwg:mainfrom
andreubotella:asynccontext
Open

AsyncContext proposal integration (part 1)#12152
andreubotella wants to merge 2 commits intowhatwg:mainfrom
andreubotella:asynccontext

Conversation

@andreubotella
Copy link
Member

@andreubotella andreubotella commented Feb 11, 2026

This PR updates HTML to integrate with the TC39 AsyncContext proposal, which allows storing state associated with an async flow of execution in JavaScript, and preserving it across different kinds of async continuations in both JS and the web platform.

This PR does not yet handle events, since the exact behavior of those with AsyncContext is still pending to be fully decided. But it covers microtasks, timers, deferred script execution, focus/blur and others.

This patch does not include any changes to the error and unhandledrejection event handling, as well as to HostEnqueueFinalizationRegistryCleanupJob. This relies on the assumption that the changes in tc39/proposal-async-context#148 and tc39/proposal-async-context#150 will be accepted. Otherwise, error contexts will need to be handled in HTML.

This patch relies on PR whatwg/webidl#1568 to define the [PropagatesAsyncContext] extended attribute in WebIDL.

This PR is part of #10432.

  • At least two implementers are interested (and none opposed):
    • Chromium
  • Tests are written and can be reviewed and commented upon at:
  • Implementation bugs are filed:
    • Chromium: …
    • Gecko: …
    • WebKit: …
    • Deno (only for timers, structured clone, base64 utils, channel messaging, module resolution, web workers, and web storage): …
    • Node.js (only for timers, structured clone, base64 utils, channel messaging, and module resolution): …
  • Corresponding HTML AAM & ARIA in HTML issues & PRs:
  • MDN issue is filed: …
  • The top of this comment includes a clear commit message to use.

(See WHATWG Working Mode: Changes for more details.)


/canvas.html ( diff )
/dnd.html ( diff )
/imagebitmap-and-animations.html ( diff )
/index.html ( diff )
/infrastructure.html ( diff )
/interaction.html ( diff )
/references.html ( diff )
/scripting.html ( diff )
/timers-and-user-prompts.html ( diff )
/webappapis.html ( diff )

This PR updates HTML to integrate with the TC39 AsyncContext proposal,
which allows storing state associated with an async flow of execution
in JavaScript, and preserving it across different kinds of async
continuations in both JS and the web platform.

This PR does not yet handle events, since the exact behavior of those
with AsyncContext is still pending to be fully decided. But it covers
microtasks, timers, deferred script execution, focus/blur and others.

This patch does not include any changes to the `error` and
`unhandledrejection` event handling, as well as to
`HostEnqueueFinalizationRegistryCleanupJob`. This relies on the
assumption that the changes in tc39/proposal-async-context#148 and
tc39/proposal-async-context#150 will be accepted. Otherwise, error
contexts will need to be handled in HTML.

This patch relies on PR [TODO] to define the
`[PropagatesAsyncContext]` extended attribute in WebIDL.
andreubotella added a commit to andreubotella/webidl that referenced this pull request Feb 11, 2026
This PR updates WebIDL to add the `[PropagatesAsyncContext]` extended
attribute. This is a part of the TC39 AsyncContext proposal, which
allows storing state associated with an async flow of execution in
JavaScript, and preserving it across different kinds of async
continuations in both JS and the web platform.

This `[PropagatesAsyncContext]` extended attribute can only be applied
to callback function types in operation arguments. When set, the
callback context will also store an Async Context Mapping, which the
callback will run in.

This allows a callback-taking operation to act like an async
continuation, and propagate the state associated with the async flow
of execution at the time that this operation is called to the
callback.

This patch relies on HTML's PR whatwg/html#12152 to define the "run
with Async Context Mapping" operation. This operation must be defined
in a web specs rather than in the TC39 proposal because it deals with
throwing in spec algorithms, which is not a concept in the TC39 specs.
andreubotella added a commit to andreubotella/webidl that referenced this pull request Feb 11, 2026
This PR updates WebIDL to add the `[PropagatesAsyncContext]` extended
attribute. This is a part of the TC39 AsyncContext proposal, which
allows storing state associated with an async flow of execution in
JavaScript, and preserving it across different kinds of async
continuations in both JS and the web platform.

This `[PropagatesAsyncContext]` extended attribute can only be applied
to callback function types in operation arguments. When set, the
callback context will also store an Async Context Mapping, which the
callback will run in.

This allows a callback-taking operation to act like an async
continuation, and propagate the state associated with the async flow
of execution at the time that this operation is called to the
callback.

This patch relies on HTML's PR whatwg/html#12152 to define the "run
with Async Context Mapping" operation. This operation must be defined
in a web specs rather than in the TC39 proposal because it deals with
throwing in spec algorithms, which is not a concept in the TC39 specs.
@Ms2ger Ms2ger mentioned this pull request Feb 11, 2026
4 tasks
@andreubotella andreubotella changed the title AsyncContext proposal integration AsyncContext proposal integration (part 1) Feb 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant