{"record":{"id":"2bc853c7d792e3e5","repo":"dotnet/runtime","slug":"failed-on-mono-wasm-get-dbg-command-info","errorCode":null,"errorMessage":"Failed on mono_wasm_get_dbg_command_info","messagePattern":"Failed on mono_wasm_get_dbg_command_info","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/mono/browser/runtime/debug.ts","lineNumber":109,"sourceCode":"export 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();\n    cwraps.mono_wasm_set_is_debugger_attached(false);\n}\n\nexport function mono_wasm_change_debugger_log_level (level: number): void {\n    forceThreadMemoryViewRefresh();\n    cwraps.mono_wasm_change_debugger_log_level(level);\n}\n\n/**","sourceCodeStart":91,"sourceCodeEnd":127,"githubUrl":"https://github.com/dotnet/runtime/blob/60108ba66eb7d1d12f595480091b4ad80a24b172/src/mono/browser/runtime/debug.ts#L91-L127","documentation":"Thrown by `mono_wasm_get_dbg_command_info` when the bootstrap command (keyed under id `0`) returns `res_ok === false`. This call fetches initial debugger bookkeeping from the native runtime; failure means the debugger handshake could not complete.","triggerScenarios":"Calling `mono_wasm_get_dbg_command_info()` (debug.ts:105) before the runtime has fully initialised its debugger, or after the debugger was detached. The native side returns a failing response for id 0 because no command info is available.","commonSituations":"Invoking the function during startup before `mono_wasm_runtime_ready`; calling it after `mono_wasm_detach_debugger`; runtime build with the debugger stubbed out (release build) that always responds with res_ok=false.","solutions":["Only call `mono_wasm_get_dbg_command_info` after `runtimeHelpers.mono_wasm_runtime_is_ready` is true.","Ensure the runtime was built with the debugger enabled (not a stripped release build).","Avoid calling it after the debugger has been detached; re-attach first if needed.","Match the debugger proxy build to the runtime build."],"exampleFix":"// before: queried before runtime ready\nmono_wasm_get_dbg_command_info(); // throws\n\n// after: wait for runtime readiness, then query\nawait runtimeReadyPromise;\nmono_wasm_get_dbg_command_info();","handlingStrategy":"validation","validationCode":"function canQueryCommandInfo () {\n  return !!runtimeHelpers.mono_wasm_runtime_is_ready;\n}\nif (canQueryCommandInfo()) mono_wasm_get_dbg_command_info();","typeGuard":"function isRuntimeReadyForDebugger (): boolean {\n  return !!runtimeHelpers.mono_wasm_runtime_is_ready;\n}","tryCatchPattern":"try {\n  return mono_wasm_get_dbg_command_info();\n} catch (e) {\n  if (e instanceof Error && /Failed on mono_wasm_get_dbg_command_info/.test(e.message)) {\n    // runtime not ready or debugger detached; defer and retry once\n    setTimeout(() => mono_wasm_get_dbg_command_info(), 100);\n    return;\n  }\n  throw e;\n}","preventionTips":["Wait for `runtimeHelpers.mono_wasm_runtime_is_ready` before querying command info.","Use a debugger-enabled runtime build for diagnostics workflows.","Do not call after `mono_wasm_detach_debugger`."],"tags":["debugger","debug-protocol","startup","diagnostics"],"backgroundTag":null,"analyzedSha":"60108ba66eb7d1d12f595480091b4ad80a24b172","analyzedAt":"2026-08-10T18:54:11.478Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}