You've already forked pocketbase
mirror of
https://github.com/pocketbase/pocketbase.git
synced 2025-11-24 07:04:51 +02:00
added DefaultClient.Send panic/recover handling as an extra precaution
This commit is contained in:
@@ -272,12 +272,14 @@ func (c *DefaultClient) IsDiscarded() bool {
|
|||||||
|
|
||||||
// Send sends the specified message to the client's channel (if not discarded).
|
// Send sends the specified message to the client's channel (if not discarded).
|
||||||
func (c *DefaultClient) Send(m Message) {
|
func (c *DefaultClient) Send(m Message) {
|
||||||
c.mu.RLock()
|
if c.IsDiscarded() {
|
||||||
defer c.mu.RUnlock()
|
|
||||||
|
|
||||||
if c.isDiscarded {
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// gracefully handle panics since channel close is not blocking and could cause races
|
||||||
|
defer func() {
|
||||||
|
recover()
|
||||||
|
}()
|
||||||
|
|
||||||
c.channel <- m
|
c.channel <- m
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user