mirror of
https://github.com/nbd-wtf/go-nostr.git
synced 2025-03-17 13:22:56 +01:00
Update subscription.go
This commit is contained in:
parent
2f368c783a
commit
41480fddda
@ -3,6 +3,7 @@ package nostr
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"log"
|
||||
"strconv"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
@ -60,6 +61,14 @@ func (sub *Subscription) GetID() string {
|
||||
func (sub *Subscription) start() {
|
||||
var mu sync.Mutex
|
||||
|
||||
// Add a defer statement with a recover function to handle panics
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
log.Printf("Recovered in start: %s\n", r)
|
||||
sub.Unsub()
|
||||
}
|
||||
}()
|
||||
|
||||
for {
|
||||
select {
|
||||
case event := <-sub.events:
|
||||
|
Loading…
x
Reference in New Issue
Block a user