Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

address review (copilot): fix stale dispatch header comment; try/finally the unhandledRejection listener cleanup

Adam Eivy380a8a9a6708
diff --git a/server/services/voice/proactiveTriggers.js b/server/services/voice/proactiveTriggers.js
index 3ab12b513f..9833fd113c 100644
--- a/server/services/voice/proactiveTriggers.js
+++ b/server/services/voice/proactiveTriggers.js
@@ -20,10 +20,11 @@
//
// EventEmitter does NOT await async listeners: a rejection from the synthesis
// path inside `speakProactive` would surface as an unhandled rejection
-// (process-killing on Node ≥15). Listeners here stay synchronous and route the
-// awaited work through `dispatch`, which try/catches internally (sanctioned
-// out-of-request-lifecycle boundary per CLAUDE.md) and never rejects; a `.catch`
-// backstop on the call site guards the rest.
+// (process-killing on Node ≥15). Listeners here stay synchronous and call the
+// async `dispatch` fire-and-forget; the single `.catch` on that call site
+// (`fire`) is the rejection boundary. `dispatch` itself uses only try/finally
+// (to release a rate-limit reservation), so a synthesis rejection propagates
+// out to that `.catch` rather than being swallowed.
import { errorEvents } from '../../lib/errorHandler.js';
import { cosEvents } from '../cosEvents.js';
diff --git a/server/services/voice/proactiveTriggers.test.js b/server/services/voice/proactiveTriggers.test.js
index 20d732dd4e..bd713e5ee1 100644
--- a/server/services/voice/proactiveTriggers.test.js
+++ b/server/services/voice/proactiveTriggers.test.js
@@ -191,21 +191,26 @@ describe('wireProactiveTriggers', () => {
const onUnhandled = (reason) => { unhandled = reason; };
process.on('unhandledRejection', onUnhandled);
- unwire = wireProactiveTriggers({ io: {}, speak, limits: { error: 60_000 } });
- errorEvents.emit('error', { severity: 'critical', message: 'boom' });
-
- // Give the rejected promise time to surface as an unhandled rejection
- // if the guard ever regresses.
- await new Promise((r) => setTimeout(r, 50));
- process.off('unhandledRejection', onUnhandled);
-
- expect(unhandled).toBeNull(); // load-bearing: locks in the no-leak guard
- expect(errorLog).toHaveBeenCalled();
-
- // Bucket did not advance — a later critical can still try.
- errorEvents.emit('error', { severity: 'critical', message: 'again' });
- await flush();
- expect(speak).toHaveBeenCalledTimes(2);
+ // try/finally so a failed assertion can't leak the process-level listener
+ // into later tests (cross-test flakiness).
+ try {
+ unwire = wireProactiveTriggers({ io: {}, speak, limits: { error: 60_000 } });
+ errorEvents.emit('error', { severity: 'critical', message: 'boom' });
+
+ // Give the rejected promise time to surface as an unhandled rejection
+ // if the guard ever regresses.
+ await new Promise((r) => setTimeout(r, 50));
+
+ expect(unhandled).toBeNull(); // load-bearing: locks in the no-leak guard
+ expect(errorLog).toHaveBeenCalled();
+
+ // Bucket did not advance — a later critical can still try.
+ errorEvents.emit('error', { severity: 'critical', message: 'again' });
+ await flush();
+ expect(speak).toHaveBeenCalledTimes(2);
+ } finally {
+ process.off('unhandledRejection', onUnhandled);
+ }
});
it('default RATE_LIMIT_MS covers all three wired sources', () => {