{"record":{"id":"02b7fdafc6d45d79","repo":"dotnet/runtime","slug":"failed-on-mono-wasm-send-dbg-command-with-parms","errorCode":null,"errorMessage":"Failed on mono_wasm_send_dbg_command_with_parms","messagePattern":"Failed on mono_wasm_send_dbg_command_with_parms","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/mono/browser/runtime/debug.ts","lineNumber":87,"sourceCode":"        _debugger_buffer_len = Math.max(command_parameters.length, _debugger_buffer_len, 256);\n        _debugger_buffer = malloc(_debugger_buffer_len);\n    }\n    const byteCharacters = atob(command_parameters);\n    const heapU8 = localHeapViewU8();\n    for (let i = 0; i < byteCharacters.length; i++) {\n        heapU8[<any>_debugger_buffer + i] = byteCharacters.charCodeAt(i);\n    }\n}\n\nexport 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 {\n    forceThreadMemoryViewRefresh();\n\n    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 {","sourceCodeStart":69,"sourceCodeEnd":105,"githubUrl":"https://github.com/dotnet/runtime/blob/60108ba66eb7d1d12f595480091b4ad80a24b172/src/mono/browser/runtime/debug.ts#L69-L105","documentation":"Thrown by `mono_wasm_send_dbg_command_with_parms` when the recorded debug-command response has `res_ok === false`. The runtime queued the response via `mono_wasm_add_dbg_command_received`; a false ok flag means the native debugger side rejected the command (bad parameters, unknown command set, or a debugger protocol error). The wrapper turns that into a thrown Error so the debugger proxy surfaces it.","triggerScenarios":"Calling `mono_wasm_send_dbg_command_with_parms(id, command_set, command, command_parameters, length, valtype, newvalue)` (debug.ts:79) where the native runtime records a failing response for `id`. This occurs when the proxy issues a set-value command with an invalid id, wrong value type, malformed base64 `command_parameters`, or an unsupported `command_set`/`command` pair.","commonSituations":"Stale debugger proxy talking to a runtime with a different debugger protocol version; trying to set a property/getter on an object id whose session has expired; sending parameters with the wrong `valtype` enum value; heap corruption resetting the debug buffer.","solutions":["Verify the `command_set` and `command` numbers match the runtime's supported debugger protocol version.","Check that `command_parameters` is a valid base64 string of the expected length and that `length` matches it.","Re-issue the command after re-attaching the debugger; an expired session id is the most common cause.","Match the dotnetDebugger/BrowserDebugProxy build to the runtime build."],"exampleFix":"// before: stale id after the runtime continued\nmono_wasm_send_dbg_command_with_parms(oldId, set, cmd, b64, len, vt, val); // throws\n\n// after: refresh the object id within the same paused state\nconst fresh = mono_wasm_send_dbg_command(curId, set, cmd, b64);\nmono_wasm_send_dbg_command_with_parms(fresh.id, set, cmd, b64, len, vt, val);","handlingStrategy":"try-catch","validationCode":"// Validate parameter shape before sending\nfunction isValidParams (command_parameters, length, valtype, newvalue) {\n  return typeof command_parameters === 'string' &&\n    command_parameters.length === length &&\n    Number.isInteger(valtype) &&\n    newvalue !== undefined;\n}","typeGuard":"function isLiveDebuggerObjectId (objId: unknown): boolean {\n  return typeof objId === 'number' && Number.isFinite(objId) && objId >= 0;\n}","tryCatchPattern":"try {\n  return mono_wasm_send_dbg_command_with_parms(id, set, cmd, params, len, vt, val);\n} catch (e) {\n  if (e instanceof Error && /Failed on mono_wasm_send_dbg_command_with_parms/.test(e.message)) {\n    // refresh ids and retry once within the same paused state\n    return mono_wasm_send_dbg_command_with_parms(freshId, set, cmd, params, len, vt, val);\n  }\n  throw e;\n}","preventionTips":["Keep the debugger paused for the lifetime of any object id you use.","Match the BrowserDebugProxy build to the runtime build.","Validate `command_parameters` length and base64 encoding before sending."],"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"}