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

ReadableStream issue @hono/node-server <> GraphQL Yoga #77

Open
maoosi opened this issue Jul 31, 2023 · 3 comments
Open

ReadableStream issue @hono/node-server <> GraphQL Yoga #77

maoosi opened this issue Jul 31, 2023 · 3 comments

Comments

@maoosi
Copy link

maoosi commented Jul 31, 2023

Issue

Since updating to @hono/[email protected], I'm having an issue using GraphQL Yoga. The server immediately crashes with the below message:

TypeError: The "readableStream" argument must be an instance of ReadableStream. Received an instance of bound PonyfillReadableStream
    at new NodeError (node:internal/errors:399:5)
    at Object.newStreamReadableFromReadableStream (node:internal/webstreams/adapters:482:11)
    at Function.Readable.fromWeb (node:internal/streams/readable:1403:27)
    at Server.<anonymous> (file:///workspace/node_modules/@hono/node-server/dist/listener.mjs:49:35)
    at processTicksAndRejections (node:internal/process/task_queues:95:5) {
  code: 'ERR_INVALID_ARG_TYPE'

Reproduction

I have created a minimal reproduction on https://codesandbox.io/p/sandbox/optimistic-lichterman-tvsgh8

Workaround

Rolling back to @hono/[email protected] fixes the issue.

@yusukebe
Copy link
Member

yusukebe commented Aug 5, 2023

Hi @maoosi

This is a workaround:

export default createYoga({
  fetchAPI: { fetch, Request, ReadableStream, Response }, // <--- Add Node.js native APIs
  graphqlEndpoint: '/',
  schema: createSchema({
    typeDefs: /* GraphQL */ `
      type Query {
        hello: String
      }
    `,
    resolvers: {
      Query: {
        hello: () => 'world'
      }
    }
  })
})

@maoosi
Copy link
Author

maoosi commented Aug 6, 2023

Thanks @yusukebe, your suggested workaround is working good on my end!

@cayter
Copy link

cayter commented Nov 4, 2023

Facing the same issue with normal static assets serving. I tried removing Readable.fromWeb() here and it worked. Is this the only place we need to update?

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

3 participants