{"record":{"id":"932a16d7a1531123","repo":"redis/go-redis","slug":"failed-to-subscribe-to-streaming-credentials-w","errorCode":null,"errorMessage":"failed to subscribe to streaming credentials: %w","messagePattern":"failed to subscribe to streaming credentials: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"redis.go","lineNumber":864,"sourceCode":"\tconn.baseClient.allowClientTracking = true\n\n\tusername, password := \"\", \"\"\n\tif c.opt.StreamingCredentialsProvider != nil {\n\t\tcredListener, initErr := c.streamingCredentialsManager.Listener(\n\t\t\tcn,\n\t\t\tc.reAuthConnection(),\n\t\t\tc.onAuthenticationErr(),\n\t\t)\n\t\tif initErr != nil {\n\t\t\tcn.GetStateMachine().Transition(pool.StateClosed)\n\t\t\treturn fmt.Errorf(\"failed to create credentials listener: %w\", initErr)\n\t\t}\n\n\t\tcredentials, unsubscribeFromCredentialsProvider, initErr := c.opt.StreamingCredentialsProvider.\n\t\t\tSubscribe(credListener)\n\t\tif initErr != nil {\n\t\t\tcn.GetStateMachine().Transition(pool.StateClosed)\n\t\t\treturn fmt.Errorf(\"failed to subscribe to streaming credentials: %w\", initErr)\n\t\t}\n\n\t\t// Per-connection unsubscribe is attached to the connection itself so it\n\t\t// runs when this specific connection is closed. Do not register it on\n\t\t// c.onClose: initConn runs for every (re)initialized connection, and\n\t\t// attaching per-connection state to the shared baseClient registry would\n\t\t// either leak entries (one per connection id, never trimmed) or — with\n\t\t// the pre-fix wrappedOnClose approach — build an unbounded closure chain\n\t\t// retaining every prior connection's unsubscribe (see issue #3772).\n\t\t//\n\t\t// Note: pool.Conn.SetOnClose OVERWRITES any prior callback (see the\n\t\t// doc on that method). That is safe here because the streaming\n\t\t// credentials Manager deduplicates listeners by connection id, so a\n\t\t// second initConn on the same cn re-Subscribes the SAME listener and\n\t\t// the returned unsubscribe is equivalent to the one already installed.\n\t\t// Any future code path that could hand out a distinct unsubscribe on\n\t\t// re-initialization must first invoke the existing one to avoid\n\t\t// orphaning the old subscription on the credentials provider.","sourceCodeStart":846,"sourceCodeEnd":882,"githubUrl":"https://github.com/redis/go-redis/blob/c5cad058c72f58370553b48566302303cf8a2e89/redis.go#L846-L882","documentation":"Error \"failed to subscribe to streaming credentials: %w\" thrown in redis/go-redis.","triggerScenarios":"Thrown at redis.go:864 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"}