Don't require hosts to handle the FinalizationRegistry context#150
Draft
andreubotella wants to merge 1 commit into
Draft
Don't require hosts to handle the FinalizationRegistry context#150andreubotella wants to merge 1 commit into
FinalizationRegistry context#150andreubotella wants to merge 1 commit into
Conversation
We currently require the `HostEnqueueFinalizationRegistryCleanupJob` host hook to set the `FinalizationRegistry`'s AsyncContext mapping in order for the FR callback to be called in the right context. However, the only reason we are doing this, rather than swapping the context in `CleanupFinalizationRegistry`, is because if we do that, hosts might not have any context information to report for any exceptions thrown from userland JS. However, given that we seem to be moving away from making hosts propagate the error context to error events and into storing the context whenever an `Error` instance is created (see #145 and #148), there's no longer any reason to make hosts handle the FR context. So this patch instead changes `CleanupFinalizationRegistry` to handle it.
andreubotella
added a commit
to andreubotella/html
that referenced
this pull request
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 [TODO] to define the `[PropagatesAsyncContext]` extended attribute in WebIDL.
6 tasks
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.
We currently require the
HostEnqueueFinalizationRegistryCleanupJobhost hook to set theFinalizationRegistry's AsyncContext mapping in order for the FR callback to be called in the right context. However, the only reason we are doing this, rather than swapping the context inCleanupFinalizationRegistry, is because if we do that, hosts might not have any context information to report for any exceptions thrown from userland JS.However, given that we seem to be moving away from making hosts propagate the error context to error events and into storing the context whenever an
Errorinstance is created (see #145 and #148), there's no longer any reason to make hosts handle the FR context. So this patch instead changesCleanupFinalizationRegistryto handle it.