dotnet/runtime · error · Error
event must be an object, but got ${JSON.stringify(event)}
Error message
event must be an object, but got ${JSON.stringify(event)} What it means
Thrown by mono_wasm_raise_debug_event() in debug.ts when the `event` argument is not of type 'object'. This function raises a debug event (e.g. breakpoint/script loaded) to the BrowserDebugProxy which listens on console.debug with a fixed magic GUID. Passing a primitive (string, number, boolean, symbol, bigint, undefined) instead of an event object is a programming contract violation. Note: typeof null === 'object', so null passes this check but will throw a TypeError on the next line accessing event.eventName.
Source
Thrown at src/mono/browser/runtime/debug.ts:132
forceThreadMemoryViewRefresh();
}
export function mono_wasm_detach_debugger (): void {
forceThreadMemoryViewRefresh();
cwraps.mono_wasm_set_is_debugger_attached(false);
}
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);View on GitHub (pinned to 290d5ab72c)
Solutions
- Pass an object literal: { eventName: '...', ...payload }.
- Ensure the variable you pass is not undefined (a missing import/typo yields undefined).
- If you intended no event, do not call the function rather than passing a primitive.
Example fix
// before
mono_wasm_raise_debug_event('breakpointHit');
// after
mono_wasm_raise_debug_event({ eventName: 'breakpointHit', id: bpId }); Defensive patterns
Strategy: type-guard
Validate before calling
function raiseDebugEventSafe(event: unknown, args?: unknown) {
if (event === null || typeof event !== "object") {
throw new TypeError('event must be a non-null object');
}
// ...then call mono_wasm_raise_debug_event(event as WasmEvent, args as any);
} Type guard
function isWasmEvent(event: unknown): event is { eventName: string } {
return event !== null && typeof event === "object"
&& typeof (event as any).eventName === "string";
} Try / catch
null
Prevention
- Always construct events as object literals with eventName.
- Type the parameter as WasmEvent so the compiler enforces it.
- Guard against null explicitly (typeof null === 'object').
When it happens
Trigger: Calling mono_wasm_raise_debug_event with a string/number/undefined instead of an object, e.g. mono_wasm_raise_debug_event('breakpoint') or mono_wasm_raise_debug_event(someId). Internal callers that build the event lazily and pass a primitive placeholder.
Common situations: Hand-written instrumentation or a fork that calls mono_wasm_raise_debug_event with a non-object. A refactor that changed what is passed in but did not wrap it in { eventName, ... }.
Related errors
- args must be an object, but got ${JSON.stringify(args)}
- 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/213466d04d2cc81d.
Report an issue: GitHub.