Skip to content

Commit e7a51b5

Browse files
committed
fix: wrong sse protocol implementation
1 parent 8cc776b commit e7a51b5

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

internal/manager/manager.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,6 @@ func (s *Service) handleSubscription(w http.ResponseWriter, r *http.Request, sch
268268
w.Header().Set("Content-Type", "text/event-stream")
269269
w.Header().Set("Cache-Control", "no-cache")
270270
w.Header().Set("Connection", "keep-alive")
271-
w.Header().Set("Transfer-Encoding", "chunked")
272271

273272
flusher := http.NewResponseController(w)
274273

@@ -291,8 +290,8 @@ func (s *Service) handleSubscription(w http.ResponseWriter, r *http.Request, sch
291290
Context: r.Context(),
292291
}
293292

294-
sub := graphql.Subscribe(subscriptionParams)
295-
for res := range sub {
293+
subscriptionChannel := graphql.Subscribe(subscriptionParams)
294+
for res := range subscriptionChannel {
296295
if res == nil {
297296
continue
298297
}
@@ -301,9 +300,11 @@ func (s *Service) handleSubscription(w http.ResponseWriter, r *http.Request, sch
301300
if err != nil {
302301
continue
303302
}
304-
fmt.Fprintf(w, "data: %s\n\n", data)
303+
fmt.Fprintf(w, "event: next\ndata: %s\n\n", data)
305304
flusher.Flush()
306305
}
306+
307+
fmt.Fprint(w, "event: complete\n\n")
307308
}
308309

309310
func readDefinitionFromFile(filePath string) (spec.Definitions, error) {

0 commit comments

Comments
 (0)