Skip to content

Commit 13285c3

Browse files
committed
fix: handle postgres query cancellation in TestAcquireJobWithCancel_Cancel
The test was failing because it was checking for context.Canceled using xerrors.Is, but postgres returns a different error ("pq: canceling statement due to user request") when a query is cancelled. This change uses database.IsQueryCanceledError which properly handles both context.Canceled and postgres-specific cancellation errors.
1 parent 04d202a commit 13285c3

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

coderd/provisionerdserver/provisionerdserver.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ func (s *server) AcquireJobWithCancel(stream proto.DRPCProvisionerDaemon_Acquire
368368
je = <-jec
369369
case je = <-jec:
370370
}
371-
if xerrors.Is(je.err, context.Canceled) {
371+
if database.IsQueryCanceledError(je.err) {
372372
s.Logger.Debug(streamCtx, "successful cancel")
373373
err := stream.Send(&proto.AcquiredJob{})
374374
if err != nil {

0 commit comments

Comments
 (0)