{"id":"547b6a47cfd06e0e","repo":"go-redis/redis","slug":"redis-channelwithsubscriptions-can-t-be-called-af","errorCode":null,"errorMessage":"redis: ChannelWithSubscriptions can't be called after Channel","messagePattern":"redis: ChannelWithSubscriptions can't be called after Channel","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pubsub.go","lineNumber":603,"sourceCode":"// 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.\nfunc (c *PubSub) ChannelWithSubscriptions(opts ...ChannelOption) <-chan interface{} {\n\tc.chOnce.Do(func() {\n\t\tc.allCh = newChannel(c, opts...)\n\t\tc.allCh.initAllChan()\n\t})\n\tif c.allCh == nil {\n\t\terr := fmt.Errorf(\"redis: ChannelWithSubscriptions can't be called after Channel\")\n\t\tpanic(err)\n\t}\n\treturn c.allCh.allCh\n}\n\nfunc (c *PubSub) processPendingPushNotificationWithReader(ctx context.Context, cn *pool.Conn, rd *proto.Reader) error {\n\t// Only process push notifications for RESP3 connections with a processor\n\tif c.opt.Protocol != 3 || c.pushProcessor == nil {\n\t\treturn nil\n\t}\n\n\t// Create handler context with client, connection pool, and connection information\n\thandlerCtx := c.pushNotificationHandlerContext(cn)\n\treturn c.pushProcessor.ProcessPendingNotifications(ctx, handlerCtx, rd)\n}\n\nfunc (c *PubSub) pushNotificationHandlerContext(cn *pool.Conn) push.NotificationHandlerContext {\n\t// PubSub doesn't have a client or connection pool, so we pass nil for those","sourceCodeStart":585,"sourceCodeEnd":621,"githubUrl":"https://github.com/go-redis/redis/blob/36d97525cd8076aed67cddf54778e9ea84550929/pubsub.go#L585-L621","documentation":"Error \"redis: ChannelWithSubscriptions can't be called after Channel\" thrown in go-redis/redis.","triggerScenarios":"Thrown at pubsub.go:603 when the library encounters an invalid state.","commonSituations":"Decide the consumption model at subscription setup, not mid-stream.","solutions":["Use only Channel on this PubSub instance once it has been called","Create a new PubSub to switch APIs"],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"analyzedSha":"36d97525cd8076aed67cddf54778e9ea84550929","analyzedAt":"2026-08-06T01:08:27.376Z","schemaVersion":2}