Repository navigation
[release/11.0] [browser] release eagerly created Task/Promise proxies on non-normal async interop paths - #136846
Open
github-actions[bot] wants to merge 2 commits into
Open
github-actions[bot] wants to merge 2 commits into
github-actions[bot] wants to merge 2 commits into
Conversation
…async interop paths (#134124)
github-actions
Bot
requested review from
lewing and
pavelsavara
as code owners
November 2, 2026 15:52
|
Azure Pipelines: Successfully started running 3 pipeline(s). 12 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
pavelsavara
temporarily deployed
to
copilot-pat-pool
November 2, 2026 15:54 — with
GitHub Actions
Inactive
Contributor
|
Tagging subscribers to 'arch-wasm': @lewing, @pavelsavara |
pavelsavara
temporarily deployed
to
copilot-pat-pool
November 2, 2026 15:56 — with
GitHub Actions
Inactive
This was referenced Nov 2, 2026
Member
|
/azp run runtime-wasm |
|
Azure Pipelines: 1 pipeline(s) were filtered out due to trigger conditions. |
Member
|
/azp run runtime-wasm |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
Member
|
Verified the actual Helix results from runtime-wasm build 1662039, not just the successful Azure DevOps build/submission legs.
The MT job is not green, but MT is not a supported product feature. Note This comment was generated with GitHub Copilot. |
kotlarmilos
approved these changes
Nov 4, 2026
This branch was previously deployed
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.
Fixes Issue #132966
main PR #134124
Backport of #134124 to release/11.0.
/cc @pavelsavara
Description
Release eagerly allocated Task/Promise proxies and managed promise holders when async JavaScript interop completes synchronously or fails before the proxy is adopted. This covers both Mono and CoreCLR browser implementations. Also complete the pre-created Task when a threaded async
[JSImport]throws, and correct holder cleanup duringJSProxyContext.Dispose.Customer Impact
#132966 reports a permanent Promise/handle leak for
[JSExport]methods returning synchronously completed Tasks: 1,000 calls retain 1,000 Promise objects and their controllers even after forced garbage collection. Repeated calls accumulate retained objects for the lifetime of the page. Other exceptional async interop paths also leak proxies; a throwing threaded async[JSImport]can leave its caller awaiting a Task that never completes.The expected behavior is to release unadopted proxies/holders and propagate failures to the awaiting caller. Changing always-synchronous exports to non-Task return types is a workaround, but does not cover methods that sometimes complete asynchronously.
Regression
Not a new .NET 11 regression: the customer reproduced the leak on .NET 10 (
net10.0-browser, SDK 10.0.400). The report identifies #95411's eager Task/Promise allocation as the origin; that introduction point has not been independently bisected here.Testing
Added
ProxyLeakTestto repeat observed and abandoned completed, pending, faulted, and throwing Task/Promise cases and assert that JS handle tables do not grow. AddedPromiseHolderLeakTest.ThrowingAsyncImport_DoesNotLeakHoldersto check the managed holder count, covering the throwing async import path that JS-side handle counts cannot detect.Backport CI evidence:
PromiseHolderLeakTest.ThrowingAsyncImport_DoesNotLeakHolderspassed.ProxyLeakTestis intentionally ST-only and was not exercised in this MT run.Original main-PR validation, not rerun locally for this backport:
These defects escaped existing coverage because it did not assert proxy/holder counts on these exceptional and synchronous-completion paths. JS-side proxy counts alone cannot detect an unadopted managed promise holder.
No local builds or tests were run for this description update. CI results above were inspected from published logs/results, not rerun. The JSWebWorker-affine catch-release path, worker teardown with live holders, and the one-/two-argument async export specializations do not have dedicated regression tests.
Risk
Medium. Changes are limited to browser async JavaScript interop cleanup and failure propagation, but affect resource ownership, reentrant disposal, and threaded dispatch in both runtime implementations. Focused leak tests, fail-first evidence from the main PR, and passing CoreCLR and Mono MT interop CI provide validation. Disposal iterates a snapshot and skips already-released holders to avoid mutation/double-free during reentrancy.
Note
This description was generated with GitHub Copilot.