Skip to content

fix(worker): prevent panic when jobs are pushed during graceful shutdown#4472

Merged
fguillot merged 1 commit into
mainfrom
fix/worker-pool-shutdown-panic
Jul 22, 2026
Merged

fix(worker): prevent panic when jobs are pushed during graceful shutdown#4472
fguillot merged 1 commit into
mainfrom
fix/worker-pool-shutdown-panic

Conversation

@fguillot

Copy link
Copy Markdown
Member

Pool.Shutdown() closed the job queue channel, but jobs can still be pushed while workers are draining: the feed scheduler ticker goroutine is never cancelled, and the UI and API refresh handlers push from detached goroutines that outlive the HTTP server shutdown. Any of them sending on the closed queue panicked the process mid-shutdown.

Keep the queue channel open and instead close a dedicated shutdown channel, guarded by sync.Once:

  • Push now selects between delivering a job and the shutdown signal, discarding jobs once shutdown begins.
  • Workers select between the queue and the shutdown signal, so they still finish their current job before Shutdown returns.

Pool.Shutdown() closed the job queue channel, but jobs can still be
pushed while workers are draining: the feed scheduler ticker goroutine
is never cancelled, and the UI and API refresh handlers push from
detached goroutines that outlive the HTTP server shutdown. Any of them
sending on the closed queue panicked the process mid-shutdown.

Keep the queue channel open and instead close a dedicated shutdown
channel, guarded by sync.Once. Push now selects between delivering a
job and the shutdown signal, discarding jobs once shutdown begins, and
workers select between the queue and the shutdown signal, so they
still finish their current job before Shutdown returns.
@fguillot
fguillot merged commit c8c414e into main Jul 22, 2026
11 checks passed
@fguillot
fguillot deleted the fix/worker-pool-shutdown-panic branch July 22, 2026 03:33
dsh2dsh added a commit to dsh2dsh/miniflux that referenced this pull request Jul 22, 2026
dsh2dsh added a commit to dsh2dsh/miniflux that referenced this pull request Jul 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant