You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(pubsub): avoid UnicodeDecodeError on reconnect with binary channel names (#3944)
* fix(pubsub): avoid UnicodeDecodeError on reconnect with binary channel names
Channels subscribed as positional arguments (without a callback handler)
may carry binary names that are not valid in the connection's encoding
(e.g. arbitrary bytes that are not valid UTF-8). The existing
`on_connect` method decoded every channel name via `force=True` to pass
them as keyword arguments to `subscribe`/`psubscribe`, which raised
`UnicodeDecodeError` for these channels.
Split the reconnection logic: channels with handlers are decoded and
passed as kwargs (they were originally subscribed as kwargs, so their
names are guaranteed decodable); channels without handlers are passed as
positional args, preserving the original bytes.
Applied the same fix to:
- async PubSub.on_connect (channels and patterns)
- sync PubSub.on_connect (channels, patterns, and shard_channels)
Added tests for binary channel and pattern reconnection in both sync
and async test suites.
Fixes#3912
* Applying review comments.
---------
Co-authored-by: petyaslavova <petya.slavova@redis.com>
0 commit comments