Skip to content

[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
release/11.0from
backport/pr-134124-to-release/11.0
Open

github-actions[bot] wants to merge 2 commits into
release/11.0from
backport/pr-134124-to-release/11.0

Conversation

@github-actions

@github-actions github-actions Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

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 during JSProxyContext.Dispose.

Customer Impact

  • Customer reported
  • Found internally

#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

  • Yes
  • No

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 ProxyLeakTest to repeat observed and abandoned completed, pending, faulted, and throwing Task/Promise cases and assert that JS handle tables do not grow. Added PromiseHolderLeakTest.ThrowingAsyncImport_DoesNotLeakHolders to check the managed holder count, covering the throwing async import path that JS-side handle counts cannot detect.

Backport CI evidence:

  • runtime build 1660167: CoreCLR JavaScript interop work items passed on V8 and Firefox.
  • runtime-wasm build 1662039: the Mono/Chrome MT JavaScript interop work item completed with 258 passed, 0 failed, 17 skipped. Uploaded XML confirms that PromiseHolderLeakTest.ThrowingAsyncImport_DoesNotLeakHolders passed. ProxyLeakTest is intentionally ST-only and was not exercised in this MT run.
  • The full MT Helix job is not green: 13 other work items failed (nine timeouts, three shutdown/BigInt errors, and an HTTP work item with seven test failures). Their relationship to this PR remains unclassified.

Original main-PR validation, not rerun locally for this backport:

  • Mono ST / Chrome / Release: 502 passed, 0 failed, 3 skipped.
  • Removing the throwing-export release caused exactly one leaked proxy per iteration (handle count 3 to 103).
  • Removing the ST throwing-import release caused the managed holder count to grow from 1 to 101.

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.

@azure-pipelines

Copy link
Copy Markdown
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 pavelsavara added arch-wasm WebAssembly architecture area-System.Runtime.InteropServices.JavaScript os-browser Browser variant of arch-wasm labels Nov 2, 2026
@pavelsavara pavelsavara added this to the 11.0.0 milestone Nov 2, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to 'arch-wasm': @lewing, @pavelsavara
See info in area-owners.md if you want to be subscribed.

@pavelsavara

Copy link
Copy Markdown
Member

/azp run runtime-wasm

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
1 pipeline(s) were filtered out due to trigger conditions.

@pavelsavara

Copy link
Copy Markdown
Member

/azp run runtime-wasm

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

@pavelsavara

pavelsavara commented Nov 4, 2026 •

Copy link
Copy Markdown
Member

Verified the actual Helix results from runtime-wasm build 1662039, not just the successful Azure DevOps build/submission legs.

  • The Mono/Chrome MT Helix job ran: 192 work items passed and 13 failed.
  • The JavaScript interop MT work item passed: 258 passed, 0 failed, 17 skipped (275 total).
  • PromiseHolderLeakTest.ThrowingAsyncImport_DoesNotLeakHolders passed, verified in the uploaded test-results XML.
  • ProxyLeakTest is explicitly single-threaded-only and was not exercised in this MT run.

The MT job is not green, but MT is not a supported product feature.

Note

This comment was generated with GitHub Copilot.

@pavelsavara pavelsavara added the Servicing-consider Issue for next servicing release review label Nov 4, 2026
@kotlarmilos kotlarmilos added Servicing-approved Approved for servicing release and removed Servicing-consider Issue for next servicing release review labels Nov 4, 2026

This branch was previously deployed

1 inactive (outdated) deployment
copilot-pat-pool — 70e57ca0 Deployed Nov 2, 2026 by pavelsavara via conclusion #11570
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arch-wasm WebAssembly architecture area-System.Runtime.InteropServices.JavaScript os-browser Browser variant of arch-wasm Servicing-approved Approved for servicing release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants