fix(task-inspector): handle lazy queue not found errors

This commit is contained in:
lhy
2026-07-23 13:05:47 +08:00
committed by lyingbug
parent 0869f3e829
commit c74b0caa35
4 changed files with 111 additions and 4 deletions
+36
View File
@@ -0,0 +1,36 @@
package router
import (
"errors"
"strings"
"github.com/hibiken/asynq"
)
const (
asynqQueueNotFoundPrefix = `NOT_FOUND: queue "`
asynqQueueNotFoundSuffix = `" does not exist`
)
// isAsynqQueueNotFound handles both the public sentinel and the internal error
// leaked by Inspector.GetQueueInfo in asynq v0.26.0.
func isAsynqQueueNotFound(err error) bool {
if err == nil {
return false
}
if errors.Is(err, asynq.ErrQueueNotFound) {
return true
}
message := err.Error()
start := strings.LastIndex(message, asynqQueueNotFoundPrefix)
if start < 0 || (start > 0 && !strings.HasSuffix(message[:start], ": ")) {
return false
}
queueAndSuffix := message[start+len(asynqQueueNotFoundPrefix):]
if !strings.HasSuffix(queueAndSuffix, asynqQueueNotFoundSuffix) {
return false
}
queue := strings.TrimSuffix(queueAndSuffix, asynqQueueNotFoundSuffix)
return queue != "" && !strings.Contains(queue, `"`)
}