Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

handle panics in queue worker #1274

Merged
merged 6 commits into from
Mar 11, 2025

Conversation

jtwaleson
Copy link
Contributor

@jtwaleson jtwaleson commented Feb 23, 2025

Users sometimes write code that panics in background job handlers. Right now the entire worker stops handling jobs when this happens. IMHO it makes sense to treat this as a regular error because that makes it easier to use Loco.

Not sure if the maintainers are open to this approach because panics should maybe be handled in the job handler implementations.

If you would like to proceed with this approach, I'll add tests and apply the same to the other worker implementations. If not, I could add some documentation on how to make job handlers panic resistant.

Users sometimes write code that panics. Right now the entire worker
stops handling jobs when this happens. It makes sense to treat this as a
regular error.
@jondot
Copy link
Contributor

jondot commented Feb 23, 2025

yes i think its a good approach, please continue

@jtwaleson jtwaleson force-pushed the panic-resilient-workers branch 2 times, most recently from 083b1b7 to bb79977 Compare February 23, 2025 14:47
@jtwaleson jtwaleson force-pushed the panic-resilient-workers branch from bb79977 to 14b3ab7 Compare February 23, 2025 14:59
@jtwaleson jtwaleson marked this pull request as ready for review February 23, 2025 15:03
@jtwaleson
Copy link
Contributor Author

Ok, this should work! I did not add a the for sidekiq, as retrieving the job status does not seem to be supported. I would not know how to elegantly test this. The Async and Sync workers are left untouched, as I assume these are mostly used in development environments and there failing fast seems preferable.

@kaplanelad kaplanelad merged commit 2e66056 into loco-rs:master Mar 11, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants