{"record":{"id":"1f3b25abec3c5e39","repo":"hibiken/asynq","slug":"asynq-unsupported-redisconnopt-type-t-1f3b25","errorCode":null,"errorMessage":"asynq: unsupported RedisConnOpt type %T","messagePattern":"asynq: unsupported RedisConnOpt type %T","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"scheduler.go","lineNumber":58,"sourceCode":"\n\t// guards idmap\n\tmu sync.Mutex\n\t// idmap maps Scheduler's entry ID to cron.EntryID\n\t// to avoid using cron.EntryID as the public API of\n\t// the Scheduler.\n\tidmap map[string]cron.EntryID\n}\n\nconst defaultHeartbeatInterval = 10 * time.Second\n\n// NewScheduler returns a new Scheduler instance given the redis connection option.\n// The parameter opts is optional, defaults will be used if opts is set to nil\nfunc NewScheduler(r RedisConnOpt, opts *SchedulerOpts) *Scheduler {\n\tscheduler := newScheduler(opts)\n\n\tredisClient, ok := r.MakeRedisClient().(redis.UniversalClient)\n\tif !ok {\n\t\tpanic(fmt.Sprintf(\"asynq: unsupported RedisConnOpt type %T\", r))\n\t}\n\n\trdb := rdb.NewRDB(redisClient)\n\n\tscheduler.rdb = rdb\n\tscheduler.client = &Client{broker: rdb, sharedConnection: false}\n\n\treturn scheduler\n}\n\n// NewSchedulerFromRedisClient returns a new instance of Scheduler given a redis.UniversalClient\n// The parameter opts is optional, defaults will be used if opts is set to nil.\n// Warning: The underlying redis connection pool will not be closed by Asynq, you are responsible for closing it.\nfunc NewSchedulerFromRedisClient(c redis.UniversalClient, opts *SchedulerOpts) *Scheduler {\n\tscheduler := newScheduler(opts)\n\n\tscheduler.rdb = rdb.NewRDB(c)\n\tscheduler.client = NewClientFromRedisClient(c)","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/hibiken/asynq/blob/d135f1439bee74e989b7f9b41ecd542cc87f024a/scheduler.go#L40-L76","documentation":"asynq.NewScheduler panics when the provided RedisConnOpt's MakeRedisClient() does not return a redis.UniversalClient. Like NewClient and NewServer, the scheduler only supports connection options backed by a go-redis UniversalClient, and an incompatible implementation causes an immediate panic at construction time.","triggerScenarios":"Passing a custom RedisConnOpt whose MakeRedisClient returns nil or a non-go-redis client type; using a wrapper/adapter struct; passing an option type from an incompatible go-redis major version.","commonSituations":"Building the scheduler with the same (broken) custom conn opt already used elsewhere; config-driven construction where an unvalidated config value produces a foreign conn-opt type; mixing asynq versions with different go-redis dependencies.","solutions":["Use built-in options: asynq.RedisClientOpt, RedisClusterClientOpt, or RedisFailoverClientOpt","If you already hold a go-redis client, build the Scheduler via NewScheduler with a valid option or adapt using an asynq-supported client constructor","Make the custom RedisConnOpt's MakeRedisClient return a redis.UniversalClient-implementing value","Assert compatibility in a small startup check: if _, ok := r.MakeRedisClient().(redis.UniversalClient); !ok { fail fast with a clear message }"],"exampleFix":"// before\nsched := asynq.NewScheduler(brokenOpt{}, nil) // panics\n\n// after\nsched, err := asynq.NewScheduler(asynq.RedisClientOpt{Addr: \":6379\"}, nil)\nif err != nil { log.Fatal(err) }","handlingStrategy":"validation","validationCode":"opt := asynq.RedisClientOpt{Addr: \":6379\"}\nif _, ok := opt.MakeRedisClient().(redis.UniversalClient); !ok {\n    log.Fatal(\"scheduler RedisConnOpt incompatible\")\n}\nsched := asynq.NewScheduler(opt, nil)","typeGuard":"func schedConnOptValid(r asynq.RedisConnOpt) bool {\n    _, ok := r.MakeRedisClient().(redis.UniversalClient)\n    return ok\n}","tryCatchPattern":null,"preventionTips":["Use built-in conn-opt types for NewScheduler","Share one validated RedisConnOpt factory across Client/Server/Scheduler/Inspector","Pin a go-redis version compatible with your asynq version","Add a unit test constructing the scheduler with the production option"],"tags":["redis","panic","scheduler","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"}