diff --git a/app/handle-count.go b/app/handle-count.go index 628ece2..bddab1c 100644 --- a/app/handle-count.go +++ b/app/handle-count.go @@ -25,7 +25,7 @@ func (l *Listener) HandleCount(msg []byte) (err error) { if _, err = env.Unmarshal(msg); chk.E(err) { return normalize.Error.Errorf(err.Error()) } - log.D.C(func() string { return fmt.Sprintf("COUNT sub=%s filters=%d", env.Subscription, len(env.Filters)) }) + log.D.C(func() string { return fmt.Sprintf("COUNT sub=%s filters=%d", env.Subscription, len(env.Filters)) }) // If ACL is active, send a challenge (same as REQ path) if acl.Registry.Active.Load() != "none" { @@ -43,14 +43,15 @@ func (l *Listener) HandleCount(msg []byte) (err error) { // allowed to read } - // Use a bounded context for counting - ctx, cancel := context.WithTimeout(l.ctx, 30*time.Second) + // Use a bounded context for counting, isolated from the connection context + // to prevent count timeouts from affecting the long-lived websocket connection + ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) defer cancel() // Aggregate count across all provided filters var total int var approx bool // database returns false per implementation - for _, f := range env.Filters { + for _, f := range env.Filters { if f == nil { continue } diff --git a/app/handle-req.go b/app/handle-req.go index 95314cb..3ba6423 100644 --- a/app/handle-req.go +++ b/app/handle-req.go @@ -86,9 +86,10 @@ func (l *Listener) HandleReq(msg []byte) (err error) { // user has read access or better, continue } var events event.S - // Create a single context for all filter queries, tied to the connection context, to prevent leaks and support timely cancellation + // Create a single context for all filter queries, isolated from the connection context + // to prevent query timeouts from affecting the long-lived websocket connection queryCtx, queryCancel := context.WithTimeout( - l.ctx, 30*time.Second, + context.Background(), 30*time.Second, ) defer queryCancel() diff --git a/pkg/version/version b/pkg/version/version index 67bca01..544d547 100644 --- a/pkg/version/version +++ b/pkg/version/version @@ -1 +1 @@ -v0.17.16 \ No newline at end of file +v0.17.17 \ No newline at end of file