-
Notifications
You must be signed in to change notification settings - Fork 133
Closed
Description
Hello! My team recently ran into an issue where returning a nil pointer to a custom error (which we use to attach our own business context) in a Work(...) function caused our whole service to die due to a panic in job_executor.go. We heavily use the custom fields in our error handler.
This can be reproduced like so:
type CustomError {
InternalErr error
}
type JobWorker struct {
river.WorkerDefaults[workers.JobWorkerArgs
}
func (jw *JobWorker) Work(ctx context.Context, job *river.Job[workers.JobWorkerArgs]) error {
var customErr *CustomError
return customErr
}Totally aware that this is a classic typed nil issue! However I believe it's unfortunate that this can compile and take down the server with very little observability.
We fixed this by adding a check everywhere that looks like this:
if customErr != nil {
return customErr
}
return nil
Would it be possible to either:
- Support pointers to custom errors (this is preferred by our team)
- Recover from the panics within the job executor to avoid bringing down the service
upalsaha and jennykwan
Metadata
Metadata
Assignees
Labels
No labels