You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
System.Threading.Tasks.TaskToAsyncResult.Begin unconditionally throws PlatformNotSupportedException on WASI:
// src/libraries/Common/src/System/Threading/Tasks/TaskToAsyncResult.cspublicstaticIAsyncResultBegin(Tasktask,AsyncCallback?callback,object?state){
#if NETif(OperatingSystem.IsWasi())thrownewPlatformNotSupportedException();// TODO remove with https://github.com/dotnet/runtime/pull/107185
The TODO points at #107185, a draft that added UnsupportedOSPlatform annotations for WASI; it was closed without merging. So the check remains and nothing tracks it.
Begin wraps a Task in an IAsyncResult and schedules the callback as a continuation. That does not need extra threads, although code that blocks on the returned AsyncWaitHandle would.
The APM helpers throughout the libraries go through it, so on WASI every Begin*/End* pattern built on TaskToAsyncResult fails, as does Task.Factory.FromAsync over such a pair. In the CoreCLR WASI library test runs on #134813, all six TaskToAsyncResultTests tests that run on a single-threaded platform fail this way. That includes InvalidArguments_ThrowExceptions, which expects ArgumentNullException.
Proposed fix
Remove the WASI check so Begin works as on browser. If blocking on AsyncWaitHandle must stay unsupported, keep that limitation where the wait happens. Otherwise, annotate the API as unsupported on WASI instead of throwing unconditionally.
Note
This issue was drafted with the help of GitHub Copilot.
Activity
dotnet-policy-service commentedon Sep 30, 2026
Tagging subscribers to 'arch-wasm': @lewing, @pavelsavara
See info in area-owners.md if you want to be subscribed.
dotnet-policy-service commentedon Sep 30, 2026
Tagging subscribers to this area: @dotnet/area-system-threading-tasks
See info in area-owners.md if you want to be subscribed.
[wasi] Quarantine TaskToAsyncResult tests on WASI
[wasi] Fix up System.IO.FileSystem.DisabledFileLocking tests on WASI
[wasi] Fix up System.Text.Encoding tests on WASI
[wasi] Quarantine TaskToAsyncResult tests on WASI
[wasi] Fix up System.IO.FileSystem.DisabledFileLocking tests on WASI
[wasi] Fix up System.Text.Encoding tests on WASI
[wasi] Quarantine TaskToAsyncResult tests on WASI
[wasi] Fix up System.IO.FileSystem.DisabledFileLocking tests on WASI
[wasi] Fix up System.Text.Encoding tests on WASI
[wasi] Quarantine TaskToAsyncResult tests on WASI
[wasi] Fix up System.IO.FileSystem.DisabledFileLocking tests on WASI
[wasi] Fix up System.Text.Encoding tests on WASI
[wasi] Quarantine TaskToAsyncResult tests on WASI
[wasi] Fix up System.IO.FileSystem.DisabledFileLocking tests on WASI
[wasi] Fix up System.Text.Encoding tests on WASI
Allow TaskToAsyncResult.Begin on WASI
[wasi] Remove placeholder PlatformNotSupportedException throws for APM (