{"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/60108ba66eb7d1d12f595480091b4ad80a24b172/src/mono/browser/runtime/debug.ts#L82-L118","documentation":"Thrown by `mono_wasm_send_dbg_command` when the queued response for `id` carries `res_ok === false`. Same contract as the with-parms variant, but for commands that take only a parameter buffer. The native debugger reported failure for the command identified by `(command_set, command)`.","triggerScenarios":"A call to `mono_wasm_send_dbg_command(id, command_set, command, command_parameters)` (debug.ts:91) where the native side records a failing response. Typically caused by an unknown/unsupported `(command_set, command)` pair, an already-completed session, or malformed parameters.","commonSituations":"BrowserDebugProxy built against a different runtime debugger protocol; calling the function after `mono_wasm_detach_debugger`; sending a command that requires an active breakpoint context which no longer exists.","solutions":["Validate the `command_set`/`command` pair against the runtime's supported debugger commands for the loaded build.","Ensure the debugger is still attached (`mono_wasm_debugger_attached` was called) before issuing the command.","Rebuild the BrowserDebugProxy and runtime together so the protocol versions align.","Log `id` plus `(command_set, command)` to correlate with the native-side rejection."],"exampleFix":"// before: command issued after detach\nmono_wasm_detach_debugger();\nmono_wasm_send_dbg_command(id, set, cmd, params); // throws\n\n// after: keep the debugger attached for the duration of the command\nmono_wasm_send_dbg_command(id, set, cmd, params);\nmono_wasm_detach_debugger();","handlingStrategy":"try-catch","validationCode":"function isSupportedCommandPair (command_set, command, supported) {\n  return supported.has(`${command_set}:${command}`);\n}","typeGuard":"function debuggerStillAttached (): boolean {\n  return runtimeHelpers.waitForDebugger !== 0;\n}","tryCatchPattern":"try {\n  return mono_wasm_send_dbg_command(id, set, cmd, params);\n} catch (e) {\n  if (e instanceof Error && /Failed on mono_wasm_send_dbg_command/.test(e.message)) {\n    mono_log_warn(`dbg command (${set},${cmd}) failed for id=${id}; re-attach and retry`);\n    mono_wasm_debugger_attached();\n    return mono_wasm_send_dbg_command(id, set, cmd, params);\n  }\n  throw e;\n}","preventionTips":["Issue debugger commands only while attached.","Confirm `(command_set, command)` is supported by the loaded runtime build.","Re-attach after detach before sending further commands."],"tags":["debugger","debug-protocol","chrome-devtools","diagnostics"],"backgroundTag":null,"analyzedSha":"60108ba66eb7d1d12f595480091b4ad80a24b172","analyzedAt":"2026-08-10T18:54:11.478Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}