Hi, I just started using River, and noticed this problem when testing. Consider the following piece of code:
type WorkFuncArgs struct{}
func (WorkFuncArgs) Kind() string { return "work_func" }
func TestSomething(t *testing.T) {
// setup...
workFunc := river.WorkFunc(func(ctx context.Context, j *river.Job[WorkFuncArgs]) error {
return river.JobSnooze(5 * time.Second)
})
worker := rivertest.NewWorker(t, riverpgxv5.New(pool), &river.Config{}, workFunc)
tx, err := pool.Begin(ctx)
require.NoError(t, err)
defer func() { _ = tx.Rollback(ctx) }()
result, err := worker.Work(queueCtx, t, tx, WorkFuncArgs{}, nil)
logger.InfoContext(ctx, "worker result", "result", result)
require.NoError(t, err)
require.Equal(t, river.EventKindJobSnoozed, result.EventKind)
}
When the job is snoozed for 1-5 seconds, the result.EventKind is job_failed, even though the job is actually correctly scheduled in 5s, Attempt is still 0, and Errors is empty:
2025-09-11T20:21:31.101+0800 INFO queue/test.go:128 worker result {"result": {"EventKind":"job_failed","Job":{"ID":1,"Attempt":0,"AttemptedAt":"2025-09-11T12:21:31.099907Z","AttemptedBy":["2024-mac-mini_local_2025_09_11T12_21_31_097812"],"CreatedAt":"2025-09-11T12:21:31.098076Z","EncodedArgs":"e30=","Errors":[],"FinalizedAt":null,"Kind":"work_func","MaxAttempts":25,"Metadata":"eyJzbm9vemVzIjogMX0=","Priority":1,"Queue":"default","ScheduledAt":"2025-09-11T12:21:36.10059Z","State":"available","Tags":[],"UniqueKey":null,"UniqueStates":null}}}
...
Not equal:
expected: "job_snoozed"
actual : "job_failed"
When the job is snoozed for 6s or more EventKind is correctly reported as job_snoozed.
I'll provide a more complete example if this isn't enough.
I didn't investigate but I wonder if this happens to have something do with the brand new PR #1037, even though that one only mentions snooze with zero duration?
Hi, I just started using River, and noticed this problem when testing. Consider the following piece of code:
When the job is snoozed for 1-5 seconds, the
result.EventKindisjob_failed, even though the job is actually correctly scheduled in 5s,Attemptis still 0, andErrorsis empty:When the job is snoozed for 6s or more
EventKindis correctly reported asjob_snoozed.I'll provide a more complete example if this isn't enough.
I didn't investigate but I wonder if this happens to have something do with the brand new PR #1037, even though that one only mentions snooze with zero duration?