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

BUN: PubSub closes after 10 seconds with (TypeError: network error) #3461

Open
schettn opened this issue Nov 6, 2024 · 1 comment
Open

Comments

@schettn
Copy link

schettn commented Nov 6, 2024

Describe the bug

Screen.Recording.2024-11-06.at.11.07.14.mov

Your Example Website or App

Steps to Reproduce the Bug or Issue

import {createPubSub, createSchema, createYoga} from 'graphql-yoga'

const pubSub = createPubSub<{
  randomNumber: [topic: number, random: number]
}>()

// Provide your schema
const yoga = createYoga({
  schema: createSchema({
    typeDefs: /* GraphQL */ `
      type Query {
        hello: String
      }

      type Subscription {
        randomNumber: Float!
      }

      type Mutation {
        broadcastRandomNumber: Boolean
      }
    `,
    resolvers: {
      Subscription: {
        randomNumber: {
          // subscribe to the randomNumber event
          subscribe: () => {
            return pubSub.subscribe('randomNumber', 1)
          },
          resolve: payload => payload
        }
      }
    }
  })
})

setInterval(() => {
  pubSub.publish('randomNumber', 1, Math.random())
}, 1000)

const server = Bun.serve({
  fetch: yoga.fetch,
  port: 4000
})

console.info(
  `Server is running on ${new URL(
    yoga.graphqlEndpoint,
    `http://${server.hostname}:${server.port}`
  )}`
)
bun run index.ts

Expected behavior

It should not close the connection

Screenshots or Videos

No response

Platform

  • OS: macOS
  • Bun: 1.1.26
  • @graphql-yoga 5.7.0

Additional context

No response

@schettn
Copy link
Author

schettn commented Nov 6, 2024

Works with NodeJS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant