From 50ce0293d5805da1365a0fafa7e39f257ae83028 Mon Sep 17 00:00:00 2001 From: "Chang, Hui-Tang" Date: Tue, 15 Oct 2024 11:28:07 +0800 Subject: [PATCH] fix: remove redundant message in streaming (#739) Because - There is a redundant `null` message at the end of streaming. This commit - Removes redundant message in streaming --- pkg/handler/triggerhandler.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pkg/handler/triggerhandler.go b/pkg/handler/triggerhandler.go index 5700c5cc8..6c2e90247 100644 --- a/pkg/handler/triggerhandler.go +++ b/pkg/handler/triggerhandler.go @@ -281,6 +281,11 @@ func HandleTrigger(mux *runtime.ServeMux, client pb.PipelinePublicServiceClient, return } } + // When using `streamHandler`, we should directly close the response once + // the event stream is completed to prevent redundant events. + if sh != nil { + return + } annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) @@ -594,6 +599,11 @@ func HandleTriggerRelease(mux *runtime.ServeMux, client pb.PipelinePublicService return } } + // When using `streamHandler`, we should directly close the response once + // the event stream is completed to prevent redundant events. + if sh != nil { + return + } annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)