oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
74.31k stars 2.78k forks source link

Error: The Request.url getter can only be used on instances of Request #12368

Open whekin opened 4 months ago

whekin commented 4 months ago

What version of Bun is running?

1.1.18+5a0b93523

What platform is your computer?

Darwin 23.5.0 arm64 arm

What steps can reproduce the bug?

Cannot use express with body parser and graphql yoga. I also tried fastify and get same error. Express works fine until I try to use the body parser. The error itself happens in this file use-health-check.ts in graphql-yoga. Specifically, this line: (17) request.url.endsWith(endpoint)

Here's a simple way to reproduce it:

Setup

bun init bun add graphql graphql-yoga express

index.ts

import { createYoga } from 'graphql-yoga'
import express from 'express';

import { createSchema } from 'graphql-yoga'

export const schema = createSchema({
  typeDefs: /* GraphQL */ `
    type Query {
      hello: String
    }
  `,
  resolvers: {
    Query: {
      hello: () => 'world'
    }
  }
})

const app = express()

app.use(express.json({ limit: '1mb' }));

const yoga = createYoga({ schema })

app.use(yoga.graphqlEndpoint, yoga)

app.listen(4000, () => {
  console.log('Running a GraphQL API server at http://localhost:4000/graphql')
})

What is the expected behavior?

No response

What do you see instead?

No response

Additional information

No response

whekin commented 1 month ago

I also tried Fastify, same error right away