{"id":"ab564cb8b4f97ada","repo":"go-redis/redis","slug":"redis-can-t-peek-push-notification-name-next-rep","errorCode":null,"errorMessage":"redis: can't peek push notification name, next reply is not a push notification","messagePattern":"redis: can't peek push notification name, next reply is not a push notification","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/proto/reader.go","lineNumber":138,"sourceCode":"//\n// To identify the name the method may block reading more bytes from the\n// underlying connection, but only ever waits for one byte beyond the valid\n// frame prefix it has already seen. That byte is guaranteed to arrive: an\n// incomplete prefix means the server is still committed to sending the rest\n// of the frame. Demanding any fixed amount instead can deadlock — a complete\n// frame such as a subscribe confirmation for a short channel name can be\n// smaller than the fixed window, and once it is buffered the server has\n// nothing more to send (issue #3935). Blocking for in-flight bytes is\n// preferred to a truncated peek, which would silently misidentify the\n// notification and cause the caller's ReadReply to consume (and drop) the\n// frame; see issue #3839.\nfunc (r *Reader) PeekPushNotificationName() (string, error) {\n\tc, err := r.rd.Peek(1)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tif c[0] != RespPush {\n\t\treturn \"\", fmt.Errorf(\"redis: can't peek push notification name, next reply is not a push notification\")\n\t}\n\n\tconst maxPushHeaderPeek = 4096\n\n\tfor {\n\t\t// Parse from what is already buffered; this never blocks.\n\t\tavail := r.rd.Buffered()\n\t\tif avail > maxPushHeaderPeek {\n\t\t\tavail = maxPushHeaderPeek\n\t\t}\n\t\tbuf, peekErr := r.rd.Peek(avail)\n\t\tif peekErr != nil {\n\t\t\treturn \"\", peekErr\n\t\t}\n\t\tname, complete, parseErr := parsePushNotificationName(buf)\n\t\tif parseErr != nil {\n\t\t\treturn \"\", parseErr\n\t\t}","sourceCodeStart":120,"sourceCodeEnd":156,"githubUrl":"https://github.com/go-redis/redis/blob/36d97525cd8076aed67cddf54778e9ea84550929/internal/proto/reader.go#L120-L156","documentation":"Error \"redis: can't peek push notification name, next reply is not a push notification\" thrown in go-redis/redis.","triggerScenarios":"Thrown at internal/proto/reader.go:138 when the library encounters an invalid state.","commonSituations":"Branch on the frame type byte before invoking push-specific parsing.","solutions":["Only call the push-name peek when a push notification frame (RESP3 '>') is actually next","Use the standard read path for non-push replies"],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"analyzedSha":"36d97525cd8076aed67cddf54778e9ea84550929","analyzedAt":"2026-08-06T01:08:27.376Z","schemaVersion":2}