{"record":{"id":"bfd9d5494d942b26","repo":"dotnet/runtime","slug":"failed-on-mono-wasm-send-dbg-command","errorCode":null,"errorMessage":"Failed on mono_wasm_send_dbg_command","messagePattern":"Failed on mono_wasm_send_dbg_command","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/mono/browser/runtime/debug.ts","lineNumber":100,"sourceCode":"    mono_wasm_malloc_and_set_debug_buffer(command_parameters);\n    cwraps.mono_wasm_send_dbg_command_with_parms(id, command_set, command, _debugger_buffer, length, valtype, newvalue.toString());\n\n    const { res_ok, res } = commands_received.remove(id);\n    if (!res_ok)\n        throw new Error(\"Failed on mono_wasm_send_dbg_command_with_parms\");\n    return res;\n}\n\nexport function mono_wasm_send_dbg_command (id: number, command_set: number, command: number, command_parameters: string): CommandResponseResult {\n    forceThreadMemoryViewRefresh();\n\n    mono_wasm_malloc_and_set_debug_buffer(command_parameters);\n    cwraps.mono_wasm_send_dbg_command(id, command_set, command, _debugger_buffer, command_parameters.length);\n\n    const { res_ok, res } = commands_received.remove(id);\n\n    if (!res_ok)\n        throw new Error(\"Failed on mono_wasm_send_dbg_command\");\n    return res;\n\n}\n\nexport function mono_wasm_get_dbg_command_info (): CommandResponseResult {\n    const { res_ok, res } = commands_received.remove(0);\n\n    if (!res_ok)\n        throw new Error(\"Failed on mono_wasm_get_dbg_command_info\");\n    return res;\n}\n\nexport function mono_wasm_debugger_resume (): void {\n    forceThreadMemoryViewRefresh();\n}\n\nexport function mono_wasm_detach_debugger (): void {\n    forceThreadMemoryViewRefresh();","sourceCodeStart":82,"sourceCodeEnd":118,"githubUrl":"https://github.com/dotnet/runtime/blob/290d5ab72cc1102813fbc0406fb186ceadabc340/src/mono/browser/runtime/debug.ts#L82-L118","documentation":"Thrown by mono_wasm_send_dbg_command() in debug.ts when the native Mono runtime marks a debugger command response as failed (res_ok=false). This is the simpler variant of the proxy command (no value/valtype parameters); it marshals a base64 command buffer to the heap and reads the reply that native pushed through mono_wasm_add_dbg_command_received. It is invoked by the proxy getters generated in _create_proxy_from_object_id (debug.ts:198) and other debugger read paths.","triggerScenarios":"A proxy property getter firing against a dotnet: object id whose native target is invalid, collected, or belongs to a paused/transitioning runtime. Issuing a debugger read command during module initialization, GC, or thread memory relocation (forceThreadMemoryViewRefresh is called but native can still fail). A stale command id reused after the command buffer was freed.","commonSituations":"Expanding a .NET object in the DevTools Watch/Scope pane while the runtime is loading or paused at a breakpoint. Evaluating expressions referencing objects from a previous debug session after hot reload. Serving a mismatched runtime wasm + debug JS bundle.","solutions":["Retry the inspection/evaluation once the runtime is no longer loading or paused.","Reload the page to reset the native command id space and the proxy cache.","Verify the served runtime .wasm matches the diagnostics/debug JS modules (rebuild and hard-refresh).","If it persists for a specific object, that object reference is stale; release it and re-acquire from the live runtime."],"exampleFix":"null","handlingStrategy":"try-catch","validationCode":"null","typeGuard":"null","tryCatchPattern":"try {\n  return mono_wasm_send_dbg_command(id, command_set, command, command_parameters);\n} catch (e) {\n  console.warn('debugger read failed', { id, command_set, command }, e);\n  return undefined;\n}","preventionTips":["Do not hold debugger object references across reloads.","Pause/resume the runtime cleanly before heavy inspection.","Keep build bundles consistent."],"tags":["debugger","native-interop","cdp","devtools"],"analyzedSha":"290d5ab72cc1102813fbc0406fb186ceadabc340","analyzedAt":"2026-08-06T19:57:01.276Z","schemaVersion":2},"datasetVersion":"2026-08-06T23:17:07.152Z"}