dotnet/runtime · error · Error
args must be an object, but got ${JSON.stringify(args)}
Error message
args must be an object, but got ${JSON.stringify(args)} What it means
Thrown by mono_wasm_raise_debug_event() in debug.ts when the `args` parameter (second argument, defaulting to {}) is not of type 'object'. args carries extra event arguments forwarded to the proxy; passing a primitive is a contract violation. The default {} means most callers never hit this; it only fires when a caller explicitly passes a non-object.
Source
Thrown at src/mono/browser/runtime/debug.ts:138
}
export function mono_wasm_change_debugger_log_level (level: number): void {
forceThreadMemoryViewRefresh();
cwraps.mono_wasm_change_debugger_log_level(level);
}
/**
* Raises an event for the debug proxy
*/
export function mono_wasm_raise_debug_event (event: WasmEvent, args = {}): void {
if (typeof event !== "object")
throw new Error(`event must be an object, but got ${JSON.stringify(event)}`);
if (event.eventName === undefined)
throw new Error(`event.eventName is a required parameter, in event: ${JSON.stringify(event)}`);
if (typeof args !== "object")
throw new Error(`args must be an object, but got ${JSON.stringify(args)}`);
// eslint-disable-next-line no-console
console.debug("mono_wasm_debug_event_raised:aef14bca-5519-4dfe-b35a-f867abc123ae", JSON.stringify(event), JSON.stringify(args));
}
export function mono_wasm_wait_for_debugger (): Promise<void> {
return new Promise<void>((resolve) => {
const interval = setInterval(() => {
if (runtimeHelpers.waitForDebugger != 1) {
return;
}
clearInterval(interval);
resolve();
}, 100);
});
}
export function mono_wasm_debugger_attached (): void {View on GitHub (pinned to 290d5ab72c)
Solutions
- Omit args (use the default {}) unless you need extra forwarded arguments.
- If you pass args, pass an object literal: { key: value }.
- Re-check argument order: (event, args).
Example fix
// before
mono_wasm_raise_debug_event(event, bpId); // bpId is a number
// after
mono_wasm_raise_debug_event(event, { bpId });
// or simply omit it
mono_wasm_raise_debug_event(event); Defensive patterns
Strategy: type-guard
Validate before calling
function raise(event: WasmEvent, args?: unknown) {
if (args !== undefined && (args === null || typeof args !== 'object' || Array.isArray(args) === false ? false : true) === false && typeof args !== 'object') {
throw new TypeError('args must be an object');
}
mono_wasm_raise_debug_event(event, (args ?? {}) as any);
} Type guard
function isPlainObject(v: unknown): v is Record<string, unknown> {
return v !== null && typeof v === "object" && !Array.isArray(v);
} Try / catch
null
Prevention
- Omit args unless you need it (default is {}).
- Keep argument order straight: (event, args).
When it happens
Trigger: Calling mono_wasm_raise_debug_event(event, 'someString') or (event, 5). A refactor passing a payload value where the args object was expected.
Common situations: Argument-position confusion: passing the payload as the second arg instead of folding it into the event object. Fork code that supplies args positionally.
Related errors
- event must be an object, but got ${JSON.stringify(event)}
- event.eventName is a required parameter, in event: ${JSON.st
- "arguments" should be an array, but was ${request.arguments}
- Failed on mono_wasm_send_dbg_command_with_parms
- Failed on mono_wasm_send_dbg_command
AI-assisted analysis of dotnet/runtime@290d5ab72c (2026-08-06).
Data as JSON: /api/errors/62a2410f8e943cee.
Report an issue: GitHub.