Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

client.SSE() block forever #3154

Open
o8x opened this issue Jun 23, 2024 · 1 comment
Open

client.SSE() block forever #3154

o8x opened this issue Jun 23, 2024 · 1 comment
Labels
help wanted Extra attention is needed SSE Server-Sent Events websocket

Comments

@o8x
Copy link
Contributor

o8x commented Jun 23, 2024

What happened?

I tried to complete a simple SSE example and passed the test using curl, but discovered the following problems while writing the go test case.

I found an unknown bug in client.SSE that will block forever once it is called. This bug appears to be for subscriptions only, as the two test cases in codegen/testserver/singlefile/defer_test.go work normally. I did not find an SSE test case for subscription in the project.

For Example:

server := handler.New(graph.NewExecutableSchema(graph.Config{
	Resolvers: &graph.Resolver{},
}))
server.AddTransport(transport.SSE{})
c := client.New(server)

sse := c.SSE(context.Background(), `subscription { 
	onTodoChange {
		action oldValue { id text done } newValue { id text done }
	}
}`)

// Never get here
var resp any
fmt.Println(sse.Next(&resp), resp)

Complete recurring use cases can be found here https://github.com/o8x/gqlgen/tree/sse-example/_examples/sse

What did you expect?

blocking in the sse.Next() method

Minimal graphql.schema and models to reproduce

type Todo {
    id: ID!
    text: String!
    done: Boolean!
}

enum TodoChangeAction {
    New
    ToggleDone
}

type TodoChangeMessage {
    newValue: Todo
    oldValue: Todo
    action: TodoChangeAction!
}

type Subscription {
    onTodoChange: TodoChangeMessage!
}

versions

  • go run github.com/99designs/gqlgen version? v0.17.49-dev
  • go version? go version go1.22.3 darwin/arm64
@StevenACoffman
Copy link
Collaborator

StevenACoffman commented Jun 23, 2024

I'm currently travelling, so this is hard to diagnose on just my cell phone. I would appreciate any help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed SSE Server-Sent Events websocket
Projects
None yet
Development

No branches or pull requests

2 participants