Bulk Job SSE Handler
Component Detail
Description
Manages Server-Sent Events streaming connections for long-running bulk operations. Opens a persistent HTTP streaming connection per background job, emits incremental progress events as records are processed, and closes the stream cleanly on completion or failure. Handles client disconnects gracefully to avoid dangling connections on the server.
bulk-job-sse-handler
Sources & reasoning
The implementation notes state explicitly that selections exceeding 100 users are submitted as background jobs with server-sent-event progress updates so the admin can navigate away and return. SSE lifecycle management is infrastructure-level concern decoupled from the business logic in BulkUserService.
No source references — this artifact was included based on reasoning alone (see above).
Responsibilities
- Open and maintain SSE connection keyed by background job ID
- Emit progress events carrying processed count and total record count
- Emit completion event with final BulkOperationResult summary
- Detect and clean up connections on client disconnect or job timeout
Interfaces
createStream(jobId: string, res: Response): void
emitProgress(jobId: string, processed: number, total: number): void
emitComplete(jobId: string, results: BulkOperationResult[]): void
emitError(jobId: string, error: string): void
closeStream(jobId: string): void