From c032cfbec56b2479439a35956b3458759e55d12f Mon Sep 17 00:00:00 2001 From: zeroaltitude Date: Sun, 8 Mar 2026 21:50:57 -0700 Subject: [PATCH] fix(test): snapshot postHookActions array in test helper to match production drain The test drainPostHookActions helper iterated the live array, but triggerInternalHook snapshots with [...(event.postHookActions ?? [])] before draining. Align test helper to match production semantics. --- src/hooks/bundled/session-memory/handler.test.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/hooks/bundled/session-memory/handler.test.ts b/src/hooks/bundled/session-memory/handler.test.ts index 98b0966629c..c192ff5f624 100644 --- a/src/hooks/bundled/session-memory/handler.test.ts +++ b/src/hooks/bundled/session-memory/handler.test.ts @@ -578,7 +578,11 @@ describe("session-memory hook", () => { async function drainPostHookActions(event: { postHookActions: Array<() => Promise | void>; }) { - for (const action of event.postHookActions) { + // Snapshot before draining — matches triggerInternalHook's production + // semantics (prevents self-scheduling actions from executing in the + // same drain cycle). + const pending = [...event.postHookActions]; + for (const action of pending) { try { await action(); } catch {