dotnet/runtime · error · Error
Failed on mono_wasm_send_dbg_command_with_parms
Error message
Failed on mono_wasm_send_dbg_command_with_parms
What it means
Thrown by mono_wasm_send_dbg_command_with_parms() in debug.ts when the native Mono runtime reports a failed debugger command. This function is the JS half of the browser debugger proxy (CDP-style) used by the Chrome DevTools / VS Code .NET WASM debugger: it marshals a command with parameters (valtype/newvalue) into a heap buffer, invokes the native mono_wasm_send_dbg_command_with_parms cwrap, then reads the response that native pushed back via mono_wasm_add_dbg_command_received. When native sets res_ok=false it means the debugger engine rejected or failed the command.
Source
Thrown at src/mono/browser/runtime/debug.ts:87
_debugger_buffer_len = Math.max(command_parameters.length, _debugger_buffer_len, 256);
_debugger_buffer = malloc(_debugger_buffer_len);
}
const byteCharacters = atob(command_parameters);
const heapU8 = localHeapViewU8();
for (let i = 0; i < byteCharacters.length; i++) {
heapU8[<any>_debugger_buffer + i] = byteCharacters.charCodeAt(i);
}
}
export function mono_wasm_send_dbg_command_with_parms (id: number, command_set: number, command: number, command_parameters: string, length: number, valtype: number, newvalue: number): CommandResponseResult {
forceThreadMemoryViewRefresh();
mono_wasm_malloc_and_set_debug_buffer(command_parameters);
cwraps.mono_wasm_send_dbg_command_with_parms(id, command_set, command, _debugger_buffer, length, valtype, newvalue.toString());
const { res_ok, res } = commands_received.remove(id);
if (!res_ok)
throw new Error("Failed on mono_wasm_send_dbg_command_with_parms");
return res;
}
export function mono_wasm_send_dbg_command (id: number, command_set: number, command: number, command_parameters: string): CommandResponseResult {
forceThreadMemoryViewRefresh();
mono_wasm_malloc_and_set_debug_buffer(command_parameters);
cwraps.mono_wasm_send_dbg_command(id, command_set, command, _debugger_buffer, command_parameters.length);
const { res_ok, res } = commands_received.remove(id);
if (!res_ok)
throw new Error("Failed on mono_wasm_send_dbg_command");
return res;
}
export function mono_wasm_get_dbg_command_info (): CommandResponseResult {View on GitHub (pinned to 290d5ab72c)
Solutions
- Retry the debugger operation after the runtime settles (it is often transient when fired during load/GC).
- Restart the debug session / reload the page so the proxy and native object id cache are reset.
- Ensure the runtime .wasm and all js-module-diagnostics/debug JS modules come from the same build (no partial cache).
- If reproducing reliably, capture the command_set/command/id and report to the dotnet/runtime repo with a minimal repro; an internal native failure should not surface as a hard throw.
Example fix
// The proxy getter in _create_proxy_from_object_id calls this; wrap callers:
// before
const v = mono_wasm_send_dbg_command_with_parms(id, cs, cmd, buf, len, vt, newVal);
// after
try {
const v = mono_wasm_send_dbg_command_with_parms(id, cs, cmd, buf, len, vt, newVal);
} catch (e) {
// object may be stale or runtime paused; surface to user, do not crash
console.warn('debugger command failed', e);
} Defensive patterns
Strategy: try-catch
Validate before calling
null
Type guard
null
Try / catch
try {
const res = mono_wasm_send_dbg_command_with_parms(id, cs, cmd, buf, len, vt, val);
return res;
} catch (e) {
// native rejected the command; object may be stale or runtime paused
console.warn('debugger command failed', { id, cs, cmd }, e);
return undefined;
} Prevention
- Avoid issuing debugger commands while the runtime is mid-load or mid-GC.
- Release stale object handles and re-acquire them after restarts.
- Serve runtime wasm and debug JS from the same build.
When it happens
Trigger: The debugger proxy calling a property setter/getter that references a stale get/set descriptor (see _create_proxy_from_object_id in debug.ts:201). A CDP `Runtime.callFunctionOn` against a dotnet: object whose native backing was collected or is on a paused runtime. The runtime being paused/transitioning (module load, GC) while a debugger property access is in flight. Native debugger engine hitting an internal error executing the command set/command id.
Common situations: Stepping/evaluating expressions during module load or while the runtime is mid-GC. Holding a stale object reference from an older evaluation after a restart/hot-reload. A version mismatch between the runtime wasm and the debug JS modules. Concurrent debugger operations racing on the shared _debugger_buffer.
Related errors
- Failed on mono_wasm_send_dbg_command
- Unknown object id ${objId}
- Could not find any object with id ${objectId}
- Failed on mono_wasm_get_dbg_command_info
- "arguments" should be an array, but was ${request.arguments}
AI-assisted analysis of dotnet/runtime@290d5ab72c (2026-08-06).
Data as JSON: /api/errors/02b7fdafc6d45d79.
Report an issue: GitHub.