[GH-ISSUE #487] How to implement custom panic recovery #1236

Open
opened 2026-03-07 22:07:51 +03:00 by kerem · 6 comments
Owner

Originally created by @mahdimehrabi on GitHub (Jun 12, 2022).
Original GitHub issue: https://github.com/hibiken/asynq/issues/487

Hi , this package able to Automatic recovery of tasks in the event of a worker crash and that's ok but I want to implement custom panic recovery to store panic and error logs in my sentry account.
are we able to set custom logger for asynq or are we able to implement our custom recovery for asynq or asynq have a custom hook when panic happens or ...

Originally created by @mahdimehrabi on GitHub (Jun 12, 2022). Original GitHub issue: https://github.com/hibiken/asynq/issues/487 Hi , this package able to **Automatic recovery of tasks in the event of a worker crash** and that's ok but I want to implement custom panic recovery to store panic and error logs in my sentry account. are we able to set custom logger for asynq or are we able to implement our custom recovery for asynq or asynq have a custom hook when panic happens or ...
Author
Owner

@linhbkhn95 commented on GitHub (Jun 15, 2022):

@mahdimehrabi Sound's good. It is useful for many situations. So I have a PR https://github.com/hibiken/asynq/pull/491 to support this feature.
please @hibiken review help me
many thanks

<!-- gh-comment-id:1156314794 --> @linhbkhn95 commented on GitHub (Jun 15, 2022): @mahdimehrabi Sound's good. It is useful for many situations. So I have a PR https://github.com/hibiken/asynq/pull/491 to support this feature. please @hibiken review help me many thanks
Author
Owner

@linhbkhn95 commented on GitHub (Jun 27, 2022):

@hibiken please review my PR #491 :((

<!-- gh-comment-id:1166816089 --> @linhbkhn95 commented on GitHub (Jun 27, 2022): @hibiken please review my PR #491 :((
Author
Owner

@hibiken commented on GitHub (Jul 2, 2022):

@mahdimehrabi Thank you for opening an issue.

@linhbkhn95 thank you for creating a PR, however, I'd like to discuss the API change here first.


The package provides ErrorHandler to let users provide error handling logic. We should leverage this existing API by wrapping the recovered panic in a custom error type (PanicError) or a sentinel error value (ErrPanic)

<!-- gh-comment-id:1172795128 --> @hibiken commented on GitHub (Jul 2, 2022): @mahdimehrabi Thank you for opening an issue. @linhbkhn95 thank you for creating a PR, however, I'd like to discuss the API change here first. --- The package provides `ErrorHandler` to let users provide error handling logic. We should leverage this existing API by wrapping the recovered panic in a custom error type (`PanicError`) or a sentinel error value (`ErrPanic`)
Author
Owner

@linhbkhn95 commented on GitHub (Jul 6, 2022):

I see If we use a wrap error to return then the client/user needs to handle this error like a callback function @hibiken

<!-- gh-comment-id:1175723523 --> @linhbkhn95 commented on GitHub (Jul 6, 2022): I see If we use a wrap error to return then the client/user needs to handle this error like a callback function @hibiken
Author
Owner

@linhbkhn95 commented on GitHub (Sep 21, 2022):

Thank @hibiken, After brainstorming again I decide to use the ErrorHandler for handling panic errors.
Please review the PR #491

<!-- gh-comment-id:1253132467 --> @linhbkhn95 commented on GitHub (Sep 21, 2022): Thank @hibiken, After brainstorming again I decide to use the ErrorHandler for handling panic errors. Please review the PR #491
Author
Owner

@linhbkhn95 commented on GitHub (Oct 19, 2022):

@hibiken can you review it for me?

<!-- gh-comment-id:1284352166 --> @linhbkhn95 commented on GitHub (Oct 19, 2022): @hibiken can you review it for me?
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
starred/asynq#1236
No description provided.