[eskit] Command bus: consider graceful drain timeout on Close() #25

Open
opened 2026-02-24 03:06:06 +00:00 by ash · 0 comments
Owner

Context

Red team audit 2026-02-24 found and fixed a panic: send on closed channel race in command.InProcessBus.

Concern

The current fix uses context cancellation to stop workers on Close(). Workers drain buffered envelopes with ErrBusClosed. However, there is no configurable drain timeout — if a handler is stuck (e.g., slow DB), Close() blocks forever on b.wg.Wait().

Suggestion

Add a WithShutdownTimeout(d time.Duration) option that caps how long Close() waits for in-flight handlers before force-killing worker goroutines.

Severity: Low (only affects shutdown path)

## Context Red team audit 2026-02-24 found and fixed a panic: send on closed channel race in command.InProcessBus. ## Concern The current fix uses context cancellation to stop workers on Close(). Workers drain buffered envelopes with ErrBusClosed. However, there is no configurable drain timeout — if a handler is stuck (e.g., slow DB), Close() blocks forever on b.wg.Wait(). ## Suggestion Add a WithShutdownTimeout(d time.Duration) option that caps how long Close() waits for in-flight handlers before force-killing worker goroutines. Severity: Low (only affects shutdown path)
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
ash/ideas#25
No description provided.