1
0
mirror of https://github.com/redis/go-redis.git synced 2025-07-19 11:43:14 +03:00

fix: copy push notification processor to transaction baseClient

- Copy pushProcessor from parent client to transaction in newTx()
- Ensure transactions inherit push notification processor from parent client
- Prevent nil pointer dereference in transaction contexts (Watch, Unwatch, etc.)
- Maintain consistent push notification behavior across all Redis operations

This fixes the panic that was occurring in transaction examples where the
transaction's baseClient had a nil pushProcessor field, causing segmentation
violations during transaction operations like Watch and Unwatch.
This commit is contained in:
Nedyalko Dyakov
2025-06-27 01:53:56 +03:00
parent d1d4529abf
commit a2de263588

7
tx.go
View File

@ -24,9 +24,10 @@ type Tx struct {
func (c *Client) newTx() *Tx {
tx := Tx{
baseClient: baseClient{
opt: c.opt,
connPool: pool.NewStickyConnPool(c.connPool),
hooksMixin: c.hooksMixin.clone(),
opt: c.opt,
connPool: pool.NewStickyConnPool(c.connPool),
hooksMixin: c.hooksMixin.clone(),
pushProcessor: c.pushProcessor, // Copy push processor from parent client
},
}
tx.init()