You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(security): late-attach mutation worker so IPC is live before its boot
CI e2e was failing across every Security spec with:
Error: page.waitForFunction: Error: Error invoking remote method
'security:get-scan-status': Error: No handler registered for
'security:get-scan-status'
Root cause: PR #N introduced `await bootMutationWorker()` between
`bootScanWorker` and `registerSecurityIpc`. Both boots have to settle
before any ipcMain.handle is wired in. The e2e harness calls
firstWindow() and immediately starts polling `security:get-scan-status`
via `waitForFunction`; an IPC rejection there propagates the throw and
ends polling on the first attempt instead of retrying. The extra
mutation-worker spawn latency pushed registration past that polling
window on every CI runner.
Fix: keep the IPC registration tight against scan-worker readiness
(the pre-PR behaviour) and defer mutation-worker plumbing.
- `registerSecurityIpc` now returns `{ dispose, attachMutationWorker }`
instead of just `dispose`.
- The mutation handlers close over a `let currentMutationWorker:
MutationWorkerProxy | null = null`, read at call time, so a worker
attached AFTER registration is picked up by every subsequent call
without re-binding the closure.
- The mutation-worker change-event forwarder daemon fiber is forked
by `attachMutationWorker(proxy)`, not at registration time. `dispose`
interrupts it alongside the scan-worker forwarders.
- In `main/index.ts`: `registerSecurityIpc` runs immediately after
`bootScanWorker` (same moment as pre-PR). `bootMutationWorker()`
fires in the background; on success its proxy is plugged in via
`securityIpc.attachMutationWorker(mutationWorker)`. Until that
runs the IPC handlers fall back to the in-process SQL path that
was already gated behind the `if (mutationWorker)` check — the
same correctness, just without the off-main offload for the boot
window.
Tests:
- The default IPC fixture in `security.test.ts` already exercises
the in-process fallback (no `attachMutationWorker` call) — what it
used to do via `mutationWorker: null` it now does by not attaching.
- The two delegation tests call `attachMutationWorker(fakeProxy)`
explicitly to pin the worker-delegated path + the
EVT_FINDINGS_CHANGED forwarder.
- Suite: 355 / 355 (no change in count, three call-sites adjusted).
0 commit comments