Introduce Ctx() for proper context management in Listener and replace direct context usage in HandleDelete with Ctx().

also introduce a 3 second timeout for websocket read failure
This commit is contained in:
2025-09-11 12:34:01 +01:00
parent bf7ca1da43
commit e2b7152221
6 changed files with 15022 additions and 13 deletions

View File

@@ -22,6 +22,12 @@ type Listener struct {
authedPubkey atomic.Bytes
}
// Ctx returns the listener's context, but creates a new context for each operation
// to prevent cancellation from affecting subsequent operations
func (l *Listener) Ctx() context.Context {
return l.ctx
}
func (l *Listener) Write(p []byte) (n int, err error) {
// Use a separate context with timeout for writes to prevent race conditions
// where the main connection context gets cancelled while writing events