dotnet/runtime · error · Error
event.eventName is a required parameter, in event: ${JSON.st
Error message
event.eventName is a required parameter, in event: ${JSON.stringify(event)} What it means
Thrown by mono_wasm_raise_debug_event() in debug.ts when `event` is an object but lacks the required `eventName` property. The BrowserDebugProxy routes events by eventName, so an anonymous event object cannot be dispatched. This is the event-contract validation that runs right after the object-type check.
Source
Thrown at src/mono/browser/runtime/debug.ts:135
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);
resolve();
}, 100);
});View on GitHub (pinned to 290d5ab72c)
Solutions
- Always set event.eventName to a known event string before raising.
- Double-check the key spelling/case: it must be exactly `eventName`.
- Type the event as WasmEvent ({ eventName: string, [k: string]: any }) so the compiler catches a missing field.
Example fix
// before
mono_wasm_raise_debug_event({ id: 1 }); // throws: no eventName
// after
mono_wasm_raise_debug_event({ eventName: 'scriptLoaded', id: 1 }); Defensive patterns
Strategy: validation
Validate before calling
function raiseEvent(event: { eventName?: string }) {
if (!event || typeof event.eventName !== 'string' || !event.eventName) {
throw new Error('eventName is required and must be a non-empty string');
}
mono_wasm_raise_debug_event(event as WasmEvent);
} Type guard
function hasEventName(e: unknown): e is { eventName: string } {
return e !== null && typeof e === "object"
&& typeof (e as any).eventName === "string";
} Try / catch
null
Prevention
- Always include eventName; double-check spelling/case.
- Use the WasmEvent type to catch missing fields at compile time.
When it happens
Trigger: Calling mono_wasm_raise_debug_event({ payload }) with no eventName field, or with eventName misspelled (e.g. EventName, event_name). A builder that spreads payload fields but forgets to set eventName.
Common situations: Refactoring event construction and dropping the eventName key. Case mismatch on the key (eventName is case-sensitive). Passing a details object where the caller expected the full event.
Related errors
- event must be an object, but got ${JSON.stringify(event)}
- args must be an object, but got ${JSON.stringify(args)}
- "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/e9a2a90f5b725b11.
Report an issue: GitHub.