{"id":"11ddeaf868afae3a","repo":"go-redis/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/go-redis/redis/blob/36d97525cd8076aed67cddf54778e9ea84550929/pubsub.go#L560-L596","documentation":"Error \"redis: Channel can't be called after ChannelWithSubscriptions\" thrown in go-redis/redis.","triggerScenarios":"Thrown at pubsub.go:578 when the library encounters an invalid state.","commonSituations":"Pick one consumption API per PubSub instance and stick to it.","solutions":["Use only ChannelWithSubscriptions on this PubSub instance once it has been called","Create a new PubSub if you need the Channel API"],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"analyzedSha":"36d97525cd8076aed67cddf54778e9ea84550929","analyzedAt":"2026-08-06T01:08:27.376Z","schemaVersion":2}