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

Segfault on v0.2.0 with GraphQL Yoga v3 #1331

Closed
enisdenjo opened this issue Oct 15, 2022 · 3 comments
Closed

Segfault on v0.2.0 with GraphQL Yoga v3 #1331

enisdenjo opened this issue Oct 15, 2022 · 3 comments
Labels
bug Something isn't working crash An issue that could cause a crash

Comments

@enisdenjo
Copy link

Version

0.2.0

Platform

Darwin Deniss-MacBook-Pro.local 21.6.0 Darwin Kernel Version 21.6.0: Mon Aug 22 20:17:10 PDT 2022; root:xnu-8020.140.49~2/RELEASE_X86_64 x86_64

What steps will reproduce the bug?

Install necessary deps:

bun install graphql graphql-yoga@three

Create a test:

// segfault.spec.ts

import { it } from 'bun:test'
import { createYoga, createSchema } from 'graphql-yoga'

it('shouldnt segfault', async () => {
  const yoga = createYoga({
    schema: createSchema({
      typeDefs: /* GraphQL */ `
        type Query {
          hello: String!
        }
      `,
      resolvers: {
        Query: {
          hello: () => 'world',
        },
      },
    }),
  })

  const server = Bun.serve(yoga)

  // segfaults during fetch
  await fetch(
    `http://${server.hostname}:${server.port}/${yoga.graphqlEndpoint}`,
    {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
      },
      body: JSON.stringify({
        query: '{ hello }',
      }),
    },
  )
})

Run tests:

bun wiptest segfault.spec.ts

Output:

segfault.spec.ts:

SegmentationFault at 0x0500000000000000


----- bun meta -----
Bun v0.2.0 (b542921f) macOS x64 21.6.0
TestCommand:
HTTP: 1
Elapsed: 181ms | User: 137ms | Sys: 40ms
RSS: 53.46MB | Peak: 53.46MB | Commit: 69.21MB | Faults: 1
----- bun meta -----

Ask for #help in https://bun.sh/discord or go to https://bun.sh/issues

How often does it reproduce? Is there a required condition?

Consistently always.

What is the expected behavior?

Doesn't segfault.

What do you see instead?

SegmentationFault at 0x0500000000000000

Additional information

The same test was passing without issues on Bun v0.1.13.

@enisdenjo enisdenjo added bug Something isn't working needs repro Needs an example to reproduce labels Oct 15, 2022
@Jarred-Sumner
Copy link
Collaborator

Thank you for writing a test

@talesmgodois
Copy link

talesmgodois commented Dec 28, 2023

So, I think this need to be checked again. Not sure if the issue is here or on the graphql-yoga repo

Bun version: 1.0.20
command: bun run src/bunApp.ts


import { createSchema, createYoga } from "graphql-yoga";

const yoga = createYoga({
  schema: createSchema({
    typeDefs: /* GraphQL */ `
      type Query {
        greetings: String
      }
    `,
    resolvers: {
      Query: {
        greetings: () => "Hello from Yoga in a Bun app!",
      },
    },
  }),
});
const server = Bun.serve({
  fetch: yoga,
});
console.info(
  `Server is running on ${new URL(
    yoga.graphqlEndpoint,
    `http://${server.hostname}:${server.port}`
  )}`
);


[1]    248648 segmentation fault (core dumped)  bun run src/server.ts

@Electroid Electroid reopened this Dec 28, 2023
@Electroid Electroid added crash An issue that could cause a crash and removed needs repro Needs an example to reproduce labels Dec 28, 2023
@Electroid
Copy link
Contributor

Both code blocks no longer crash and work normally.

bun/test on  main [$!?] via 🍞 v1.0.26 via  v21.5.0 on ☁️  (us-east-1) on ☁️  ashcon@bun.sh 
❯ bun test index.test.ts
bun test v1.0.26 (1f0c1c81)

index.test.ts:
✓ shouldnt segfault [29.90ms]

 1 pass
 0 fail
Ran 1 tests across 1 files. [156.00ms]
❯ bun index.test.ts 
Server is running on http://localhost:3000/graphql

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working crash An issue that could cause a crash
Projects
None yet
Development

No branches or pull requests

4 participants