fix: default postHookActions to [] for legacy callers

Legacy callers constructing hook events without postHookActions would
hit a TypeError when drainPostHookActions spreads undefined. Now
defaults to empty array at trigger time for backwards compatibility.
This commit is contained in:
zeroaltitude 2026-03-09 23:24:28 -07:00
parent 2ae019c330
commit 9744fa0b06
No known key found for this signature in database
GPG Key ID: 77592FB1C703882E

View File

@ -297,7 +297,10 @@ export async function triggerInternalHook(event: InternalHookEvent): Promise<voi
// callbacks do not execute in this drain cycle. Without this, a self-
// scheduling action (one that pushes another action) could loop infinitely
// because Array's for...of iterator is live and re-reads length each step.
await drainPostHookActions(event.postHookActions, (err) => {
// Default to empty array for legacy callers that construct hook events
// without the postHookActions field (pre-dates this PR's event shape change).
const actions = event.postHookActions ?? [];
await drainPostHookActions(actions, (err) => {
const message = err instanceof Error ? err.message : String(err);
log.error(`Post-hook action error [${event.type}:${event.action}]: ${message}`);
});