@@ -65,7 +65,7 @@ type Resolver struct {
65
65
66
66
propagateSubgraphErrors bool
67
67
propagateSubgraphStatusCodes bool
68
- // Multipart heartbeat interval
68
+ // Subscription heartbeat interval
69
69
heartbeatInterval time.Duration
70
70
// maxSubscriptionFetchTimeout defines the maximum time a subscription fetch can take before it is considered timed out
71
71
maxSubscriptionFetchTimeout time.Duration
@@ -306,8 +306,8 @@ func (s *sub) startWorker() {
306
306
s .startWorkerWithoutHeartbeat ()
307
307
}
308
308
309
- // startWorkerWithHeartbeat is similar to startWorker but sends heartbeats to the client when
310
- // subscription over multipart is used. It sends a heartbeat to the client every heartbeatInterval.
309
+ // startWorkerWithHeartbeat is similar to startWorker but sends heartbeats to the client when enabled.
310
+ // It sends a heartbeat to the client every heartbeatInterval. Heartbeats are handled by the SubscriptionResponseWriter interface .
311
311
// TODO: Implement a shared timer implementation to avoid creating a new ticker for each subscription.
312
312
func (s * sub ) startWorkerWithHeartbeat () {
313
313
heartbeatTicker := time .NewTicker (s .resolver .heartbeatInterval )
@@ -515,16 +515,13 @@ func (r *Resolver) handleHeartbeat(sub *sub) {
515
515
}
516
516
517
517
if err := sub .writer .Heartbeat (); err != nil {
518
- if errors .Is (err , context .Canceled ) {
519
- // If Write fails (e.g. client disconnected), remove the subscription.
520
- _ = r .AsyncUnsubscribeSubscription (sub .id )
521
- return
522
- }
523
- r .asyncErrorWriter .WriteError (sub .ctx , err , nil , sub .writer )
518
+ // If heartbeat fails (e.g. client disconnected), remove the subscription.
519
+ _ = r .AsyncUnsubscribeSubscription (sub .id )
520
+ return
524
521
}
525
522
526
523
if r .options .Debug {
527
- fmt .Printf ("resolver:heartbeat:subscription:flushed :%d\n " , sub .id .SubscriptionID )
524
+ fmt .Printf ("resolver:heartbeat:subscription:done :%d\n " , sub .id .SubscriptionID )
528
525
}
529
526
530
527
if r .reporter != nil {
0 commit comments