Skip to content

Commit e1e960b

Browse files
committed
grpc transport v2
Signed-off-by: Wei Liu <[email protected]>
1 parent 139492a commit e1e960b

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

pkg/cloudevents/server/grpc/broker.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,6 @@ func (bkr *GRPCBroker) Subscribe(subReq *pbv1.SubscriptionRequest, subServer pbv
217217
// WARNING: don't use "pbEvt, err := pb.ToProto(evt)" to convert cloudevent to protobuf
218218
pbEvt := &pbv1.CloudEvent{}
219219
if err := grpcprotocol.WritePBMessage(context.TODO(), binding.ToMessage(evt), pbEvt); err != nil {
220-
// return the error to requeue the event if converting to protobuf fails (e.g., due to invalid cloudevent).
221220
return fmt.Errorf("failed to convert cloudevent to protobuf for resource(%s): %v", evt.ID(), err)
222221
}
223222

@@ -226,7 +225,12 @@ func (bkr *GRPCBroker) Subscribe(subReq *pbv1.SubscriptionRequest, subServer pbv
226225
select {
227226
case eventCh <- pbEvt:
228227
case <-ctx.Done():
229-
return status.Error(codes.Unavailable, "stream context canceled")
228+
// The context of the stream has been canceled or completed.
229+
// This could happen if:
230+
// - The client closed the connection or canceled the stream.
231+
// - The server closed the stream, potentially due to a shutdown.
232+
// No error is returned here because the stream closure is expected.
233+
return nil
230234
}
231235

232236
return nil

0 commit comments

Comments
 (0)