{"record":{"id":"8a5e39c19dee0265","repo":"hibiken/asynq","slug":"asynq-unsupported-redisconnopt-type-t-8a5e39","errorCode":null,"errorMessage":"asynq: unsupported RedisConnOpt type %T","messagePattern":"asynq: unsupported RedisConnOpt type %T","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"server.go","lineNumber":434,"sourceCode":"\tdefaultShutdownTimeout = 8 * time.Second\n\n\tdefaultHealthCheckInterval = 15 * time.Second\n\n\tdefaultDelayedTaskCheckInterval = 5 * time.Second\n\n\tdefaultGroupGracePeriod = 1 * time.Minute\n\n\tdefaultJanitorInterval = 8 * time.Second\n\n\tdefaultJanitorBatchSize = 100\n)\n\n// NewServer returns a new Server given a redis connection option\n// and server configuration.\nfunc NewServer(r RedisConnOpt, cfg Config) *Server {\n\tredisClient, ok := r.MakeRedisClient().(redis.UniversalClient)\n\tif !ok {\n\t\tpanic(fmt.Sprintf(\"asynq: unsupported RedisConnOpt type %T\", r))\n\t}\n\tserver := NewServerFromRedisClient(redisClient, cfg)\n\tserver.sharedConnection = false\n\treturn server\n}\n\n// NewServerFromRedisClient returns a new instance of Server given a redis.UniversalClient\n// and server configuration\n// Warning: The underlying redis connection pool will not be closed by Asynq, you are responsible for closing it.\nfunc NewServerFromRedisClient(c redis.UniversalClient, cfg Config) *Server {\n\tbaseCtxFn := cfg.BaseContext\n\tif baseCtxFn == nil {\n\t\tbaseCtxFn = context.Background\n\t}\n\tn := cfg.Concurrency\n\tif n < 1 {\n\t\tn = runtime.NumCPU()\n\t}","sourceCodeStart":416,"sourceCodeEnd":452,"githubUrl":"https://github.com/hibiken/asynq/blob/d135f1439bee74e989b7f9b41ecd542cc87f024a/server.go#L416-L452","documentation":"asynq.NewServer panics when the provided RedisConnOpt's MakeRedisClient() does not return a redis.UniversalClient. The server requires a go-redis UniversalClient for its broker operations, and any incompatible connection-option implementation causes this immediate panic instead of a returned error.","triggerScenarios":"Constructing asynq.NewServer with a custom RedisConnOpt whose MakeRedisClient returns nil or a non-go-redis client; passing a wrapper/adaptor type; using a conn-opt from a mismatched go-redis major version; passing an unvalidated config-driven conn opt.","commonSituations":"Custom RedisConnOpt implementations written against a different Redis library; DI containers supplying the wrong option type; upgrading go-redis so the UniversalClient interface no longer matches what MakeRedisClient returns.","solutions":["Use asynq.RedisClientOpt, RedisClusterClientOpt, or RedisFailoverClientOpt to configure the server","If you already hold a go-redis client, use asynq.NewServerFromRedisClient instead","Make custom RedisConnOpt's MakeRedisClient return a value implementing redis.UniversalClient","Add a startup type check: if _, ok := r.MakeRedisClient().(redis.UniversalClient); !ok { return a clear config error before calling NewServer }"],"exampleFix":"// before\nsrv := asynq.NewServer(myRedigoOpt{}, asynq.Config{}) // panics\n\n// after\nsrv := asynq.NewServer(asynq.RedisClientOpt{Addr: \"localhost:6379\"}, asynq.Config{Concurrency: 10})","handlingStrategy":"validation","validationCode":"opt := asynq.RedisClientOpt{Addr: \":6379\"}\nif _, ok := opt.MakeRedisClient().(redis.UniversalClient); !ok {\n    log.Fatal(\"server RedisConnOpt must yield a go-redis UniversalClient\")\n}\nsrv := asynq.NewServer(opt, asynq.Config{})","typeGuard":"func serverConnOptValid(r asynq.RedisConnOpt) bool {\n    _, ok := r.MakeRedisClient().(redis.UniversalClient)\n    return ok\n}","tryCatchPattern":null,"preventionTips":["Use asynq.RedisClientOpt / RedisClusterClientOpt / RedisFailoverClientOpt for the server","Use NewServerFromRedisClient when you already hold a go-redis client","Keep custom MakeRedisClient implementations returning go-redis UniversalClient types","Add a startup smoke test that constructs the Server with the production conn opt"],"tags":["redis","panic","server","configuration","go"],"backgroundTag":"type-mismatch","analyzedSha":"d135f1439bee74e989b7f9b41ecd542cc87f024a","analyzedAt":"2026-09-07T19:02:34.660Z","contentChangedAt":"2026-09-07T19:02:34.660Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}