{"record":{"id":"e9a2a90f5b725b11","repo":"dotnet/runtime","slug":"event-eventname-is-a-required-parameter-in-event","errorCode":null,"errorMessage":"event.eventName is a required parameter, in event: ${JSON.stringify(event)}","messagePattern":"event\\.eventName is a required parameter, in event: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/mono/browser/runtime/debug.ts","lineNumber":135,"sourceCode":"export 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/**\n * Raises an event for the debug proxy\n */\nexport function mono_wasm_raise_debug_event (event: WasmEvent, args = {}): void {\n    if (typeof event !== \"object\")\n        throw new Error(`event must be an object, but got ${JSON.stringify(event)}`);\n\n    if (event.eventName === undefined)\n        throw new Error(`event.eventName is a required parameter, in event: ${JSON.stringify(event)}`);\n\n    if (typeof args !== \"object\")\n        throw new Error(`args must be an object, but got ${JSON.stringify(args)}`);\n\n    // eslint-disable-next-line no-console\n    console.debug(\"mono_wasm_debug_event_raised:aef14bca-5519-4dfe-b35a-f867abc123ae\", JSON.stringify(event), JSON.stringify(args));\n}\n\nexport function mono_wasm_wait_for_debugger (): Promise<void> {\n    return new Promise<void>((resolve) => {\n        const interval = setInterval(() => {\n            if (runtimeHelpers.waitForDebugger != 1) {\n                return;\n            }\n            clearInterval(interval);\n            resolve();\n        }, 100);\n    });","sourceCodeStart":117,"sourceCodeEnd":153,"githubUrl":"https://github.com/dotnet/runtime/blob/290d5ab72cc1102813fbc0406fb186ceadabc340/src/mono/browser/runtime/debug.ts#L117-L153","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nmono_wasm_raise_debug_event({ id: 1 });  // throws: no eventName\n\n// after\nmono_wasm_raise_debug_event({ eventName: 'scriptLoaded', id: 1 });","handlingStrategy":"validation","validationCode":"function raiseEvent(event: { eventName?: string }) {\n  if (!event || typeof event.eventName !== 'string' || !event.eventName) {\n    throw new Error('eventName is required and must be a non-empty string');\n  }\n  mono_wasm_raise_debug_event(event as WasmEvent);\n}","typeGuard":"function hasEventName(e: unknown): e is { eventName: string } {\n  return e !== null && typeof e === \"object\"\n    && typeof (e as any).eventName === \"string\";\n}","tryCatchPattern":"null","preventionTips":["Always include eventName; double-check spelling/case.","Use the WasmEvent type to catch missing fields at compile time."],"tags":["debugger","events","contracts","validation"],"analyzedSha":"290d5ab72cc1102813fbc0406fb186ceadabc340","analyzedAt":"2026-08-06T19:57:01.276Z","schemaVersion":2},"datasetVersion":"2026-08-06T23:17:07.152Z"}