{"record":{"id":"a6842385ae65d07f","repo":"redis/go-redis","slug":"redis-channel-can-t-be-called-after-channelwithsu","errorCode":null,"errorMessage":"redis: Channel can't be called after ChannelWithSubscriptions","messagePattern":"redis: Channel can't be called after ChannelWithSubscriptions","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pubsub.go","lineNumber":578,"sourceCode":"\treturn context.Background()\n}\n\n//------------------------------------------------------------------------------\n\n// Channel returns a Go channel for concurrently receiving messages.\n// The channel is closed together with the PubSub. If the Go channel\n// is blocked full for 1 minute the message is dropped.\n// Receive* APIs can not be used after channel is created.\n//\n// go-redis periodically sends ping messages to test connection health\n// and re-subscribes if ping can not received for 1 minute.\nfunc (c *PubSub) Channel(opts ...ChannelOption) <-chan *Message {\n\tc.chOnce.Do(func() {\n\t\tc.msgCh = newChannel(c, opts...)\n\t\tc.msgCh.initMsgChan()\n\t})\n\tif c.msgCh == nil {\n\t\terr := fmt.Errorf(\"redis: Channel can't be called after ChannelWithSubscriptions\")\n\t\tpanic(err)\n\t}\n\treturn c.msgCh.msgCh\n}\n\n// ChannelSize is like Channel, but creates a Go channel\n// with specified buffer size.\n//\n// Deprecated: use Channel(WithChannelSize(size)), remove in v9.\nfunc (c *PubSub) ChannelSize(size int) <-chan *Message {\n\treturn c.Channel(WithChannelSize(size))\n}\n\n// ChannelWithSubscriptions is like Channel, but message type can be either\n// *Subscription or *Message. Subscription messages can be used to detect\n// reconnections.\n//\n// ChannelWithSubscriptions can not be used together with Channel or ChannelSize.","sourceCodeStart":560,"sourceCodeEnd":596,"githubUrl":"https://github.com/redis/go-redis/blob/c5cad058c72f58370553b48566302303cf8a2e89/pubsub.go#L560-L596","documentation":"Error \"redis: Channel can't be called after ChannelWithSubscriptions\" thrown in redis/go-redis.","triggerScenarios":"Thrown at pubsub.go:578 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"c5cad058c72f58370553b48566302303cf8a2e89","analyzedAt":"2026-09-01T06:50:53.388Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}