Skip to content

Commit 5ee0b11

Browse files
Copilotxperiandri
andauthored
Handle deferred initial send state safely
Co-authored-by: xperiandri <2365592+xperiandri@users.noreply.github.com>
1 parent ba21ee7 commit 5ee0b11

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

‎src/FSharp.Data.GraphQL.Server.AspNetCore/GraphQLWebsocketMiddleware.fs‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -430,9 +430,7 @@ type GraphQLWebSocketMiddleware<'Root>
430430
| ValueSome pending ->
431431
pendingTerminal <- ValueNone
432432
Choice2Of2 (ValueSome pending)
433-
| ValueNone ->
434-
initialPayloadSent <- true
435-
Choice2Of2 ValueNone)
433+
| ValueNone -> Choice2Of2 ValueNone)
436434
with
437435
| Choice1Of2 outputsToFlush ->
438436
for output in outputsToFlush do
@@ -539,6 +537,7 @@ type GraphQLWebSocketMiddleware<'Root>
539537
reraise ()
540538

541539
enqueueSend (fun () -> task {
540+
lock gate (fun () -> initialPayloadSent <- true)
542541
do!
543542
SubscriptionExecutionResult.CreateInitial (data, errors, delivery.TakePendingVisibleIn data)
544543
|> sendOutput id

0 commit comments

Comments
 (0)