dotnet / dotnet/runtime

[wasm][11.0 preview 4] WasmEnableThreads=true fails at startup: `r.mono_wasm_setenv is not a function`

Open
#128,601 2 comments 0 reactions 1 assignee Claimed by @pavelsavara View on GitHub
arch-wasm area-Build-mono os-browser
Dominant language
C#
Stars
18.3k
Forks
5.6k
PR merge metrics
PR metrics pending

Description

### Description

A Blazor WebAssembly app targeting `net11.0` with `true` fails to start at runtime on .NET 11 preview 4. The deputy worker throws `TypeError: r.mono_wasm_setenv is not a function`, `mono_wasm_start_deputy_thread_async()` fails, and Blazor never boots. The same project works with threads enabled on `net10.0`, and works on `net11.0` preview 4 with `WasmEnableThreads=false`.

### Minimal repro

Repo: https://github.com/slang25/blazor-wasm-threads-preview4-repro

It is a vanilla `dotnet new blazorwasm` template. The only changes from the template are in the `.csproj`:

- `net11.0`
- `true`
- Both `Microsoft.AspNetCore.Components.WebAssembly` and `…WebAssembly.DevServer` bumped to `11.0.0-preview.4.26230.115`

Steps:

1. `git clone https://github.com/slang25/blazor-wasm-threads-preview4-repro`
2. `dotnet workload install wasm-tools` (preview 4 manifests must match)
3. `dotnet run`
4. Open the printed URL in Chrome and check DevTools console.

### Configuration

- .NET SDK: `11.0.100-preview.4.26230.115`
- `wasm-tools` workload: `11.0.100-preview.4.26230.115`
- `Microsoft.AspNetCore.Components.WebAssembly`: `11.0.0-preview.4.26230.115`
- `Microsoft.AspNetCore.Components.WebAssembly.DevServer`: `11.0.0-preview.4.26230.115`
- OS: macOS 15 (Darwin 25.5.0), arm64
- Browser: Chrome (latest)

### Regression?

Yes — same project on `net10.0` (`Microsoft.AspNetCore.Components.WebAssembly` 10.0.x) with `WasmEnableThreads=true` works fine.

### Expected behavior

The default Blazor WASM page renders.

### Actual behavior

Page is blank. DevTools console:

```
MONO_WASM: onRuntimeInitializedAsync() failed Error: mono_wasm_start_deputy_thread_async() failed
TypeError: r.mono_wasm_setenv is not a function
at .../dotnet.runtime..js:3:32103
at Worker. (.../dotnet.runtime..js:3:32336)

worker sent an error! .../dotnet.native.worker..mjs:1: Uncaught TypeError: r.mono_wasm_setenv is not a function

Error: Failed to start platform. Reason: Error: mono_wasm_start_deputy_thread_async() failed
TypeError: r.mono_wasm_setenv is not a function
```

The shipped `dotnet.runtime.js` does declare the cwrap (`[!0,"mono_wasm_setenv",null,["string","string"]]`) and calls it as `r.mono_wasm_setenv(e,t)`, but on the deputy worker the binding is `undefined` at call time.

### Workaround

`false` — the page then loads with no errors.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.