diff --git a/src/hooks/internal-hooks.ts b/src/hooks/internal-hooks.ts index 08a642a17e0..fec142b5d54 100644 --- a/src/hooks/internal-hooks.ts +++ b/src/hooks/internal-hooks.ts @@ -213,10 +213,10 @@ export type InternalHookHandler = (event: InternalHookEvent) => Promise | const _g = globalThis as typeof globalThis & { __openclaw_internal_hook_handlers__?: Map; }; -if (!_g.__openclaw_internal_hook_handlers__) { - _g.__openclaw_internal_hook_handlers__ = new Map(); -} -const handlers = _g.__openclaw_internal_hook_handlers__; +const handlers = (_g.__openclaw_internal_hook_handlers__ ??= new Map< + string, + InternalHookHandler[] +>()); const log = createSubsystemLogger("internal-hooks"); /**