You've already forked pocketbase
mirror of
https://github.com/pocketbase/pocketbase.git
synced 2025-11-23 22:55:37 +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).
|
||||
func (c *DefaultClient) Send(m Message) {
|
||||
c.mu.RLock()
|
||||
defer c.mu.RUnlock()
|
||||
|
||||
if c.isDiscarded {
|
||||
if c.IsDiscarded() {
|
||||
return
|
||||
}
|
||||
|
||||
// gracefully handle panics since channel close is not blocking and could cause races
|
||||
defer func() {
|
||||
recover()
|
||||
}()
|
||||
|
||||
c.channel <- m
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user