Skip to content

Comments

[Repo Assist] Fix ofAsyncEnum deadlock on single-threaded runtimes (Blazor WASM)#229

Merged
dsyme merged 1 commit intomainfrom
repo-assist/fix-ofasyncsenum-dispose-wasm-deadlock-issue152-0a3ae3e9fadf4869
Feb 22, 2026
Merged

[Repo Assist] Fix ofAsyncEnum deadlock on single-threaded runtimes (Blazor WASM)#229
dsyme merged 1 commit intomainfrom
repo-assist/fix-ofasyncsenum-dispose-wasm-deadlock-issue152-0a3ae3e9fadf4869

Conversation

@github-actions
Copy link
Contributor

🤖 Repo Assist here — I'm an automated AI assistant for this repository.

Closes #152

Root Cause

AsyncSeq.ofAsyncEnum registers an IDisposable cleanup to call DisposeAsync() on the underlying IAsyncEnumerator. The previous implementation waited for disposal synchronously:

e.DisposeAsync().AsTask() |> Async.AwaitTask |> Async.RunSynchronously

On single-threaded runtimes such as Blazor WASM, Async.RunSynchronously blocks the only available thread. The DisposeAsync task then needs that same thread to complete — causing a deadlock.

Fix

Replace the blocking call with a fire-and-forget:

e.DisposeAsync() |> ignore

ValueTask starts execution immediately; ignoring the return value simply means we do not wait for it. For synchronous enumerators (the common case) the ValueTask is already complete when returned, so there is no observable difference. For asynchronous enumerators the cleanup still happens — we just do not block waiting for it, which is consistent with how IDisposable.Dispose() behaves throughout the rest of the library.

Test Status

  • Build passes
  • All 190 tests pass (dotnet test)

Generated by Repo Assist

To install this workflow, run gh aw add githubnext/agentics/workflows/repo-assist.md@b0296681ad309e6455276244363810b1e7d98335. View source at https://github.com/githubnext/agentics/tree/b0296681ad309e6455276244363810b1e7d98335/workflows/repo-assist.md.

Replace Async.RunSynchronously in IDisposable.Dispose with fire-and-forget
to avoid blocking the only available thread on platforms such as Blazor WASM.

Closes #152

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@dsyme dsyme marked this pull request as ready for review February 22, 2026 06:54
@dsyme dsyme closed this Feb 22, 2026
@dsyme dsyme reopened this Feb 22, 2026
@dsyme dsyme merged commit cc4fa61 into main Feb 22, 2026
1 check passed
github-actions bot added a commit that referenced this pull request Feb 22, 2026
- Add mapAsyncUnorderedParallelThrottled (closes #31, PR #225)
- Fix ofAsyncEnum deadlock on single-threaded runtimes like Blazor WASM (closes #152, PR #229)
- Update PackageLicenseExpression and Microsoft.Bcl.AsyncInterfaces to 10.0.3 (closes #168, PR #228)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
dsyme added a commit that referenced this pull request Feb 22, 2026
* Prepare release 3.3.2

- Add mapAsyncUnorderedParallelThrottled (closes #31, PR #225)
- Fix ofAsyncEnum deadlock on single-threaded runtimes like Blazor WASM (closes #152, PR #229)
- Update PackageLicenseExpression and Microsoft.Bcl.AsyncInterfaces to 10.0.3 (closes #168, PR #228)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Bump version to 4.0.0 (#237)

* Initial plan

* Update version from 3.3.2 to 4.0.0 in RELEASE_NOTES.md and version.props

Co-authored-by: dsyme <7204669+dsyme@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: dsyme <7204669+dsyme@users.noreply.github.com>

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Co-authored-by: dsyme <7204669+dsyme@users.noreply.github.com>
Co-authored-by: Don Syme <dsyme@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant