Problem#
All in-process events (task.updated, task.stuck, job.created/completed/failed, artefacts.synced) still used the in-process EventEmitter2 bus, making them invisible to horizontally-scaled workers and inaccessible via Redis. This blocked AW-1's multi-worker architecture from receiving real-time pipeline state changes.
Task / Link#
Closes #444 — AW-8: Migrate EventEmitter2 events to EventBusService
Depends on #443 (AW-7: EventBusService backed by Redis) — merged into this branch.
Changes#
- R1 (task.updated):
TaskStateServiceemits viaEventBusService;WsGatewayServiceandMetricsCacheregister handlers viaeventBus.on()inonModuleInit - R2 (task.stuck):
WatchdogServiceemits viaEventBusService - R3 (artefacts.synced):
PhaseRouterServiceemits viaEventBusService - R4 (job.completed/job.failed):
SqliteJobQueueemits viaEventBusService - R5 (job.created): Replace 3× self-trigger emits with direct
void this.processNext()calls; Redis emit added for multi-instance support - R6 (cleanup):
npm uninstall @nestjs/event-emitter; allEventEmitterModule.forRoot()andEventEmitter2imports removed - All spec/integration/e2e files updated to use
EventBusServicemocks
Notes#
- All
eventBus.emit()calls are wrapped in try/catch to avoid breaking pipeline if Redis publish fails - The
job.createdself-trigger migration (R5) uses directprocessNext()call — simpler and more reliable than pub/sub for single-instance; Redis emit future-proofs multi-instance - Unit tests for
SqliteJobQueueadjusted: enqueue now directly callsprocessNext, tests register handler after enqueue to avoid race conditions
Testing#
npm run lint— passed (zero warnings)npm run test— 807/807 tests passed