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 when calling Server#fetch with .routes #18077

Open
jclem opened this issue Mar 11, 2025 · 4 comments · May be fixed by #18151
Open

Segfault when calling Server#fetch with .routes #18077

jclem opened this issue Mar 11, 2025 · 4 comments · May be fixed by #18151
Labels
confirmed bug We can reproduce this issue crash An issue that could cause a crash runtime

Comments

@jclem
Copy link

jclem commented Mar 11, 2025

How can we reproduce the crash?

I'm trying to write tests using server.fetch(request). The server file only has this:

export const server = Bun.serve({
  routes: {
    "/": () => Response.json({ ok: true }),
  },

  port: process.env.PORT ?? 3000,
});

This segmentation fault happens when calling server.fetch(request).

Relevant log output

Stack Trace (bun.report)

Bun v1.2.5 (013fddd) on macos aarch64 [TestCommand]

Segmentation fault at address 0x00000000

  • 1 unknown/js code
  • DebugHTTPSServerPrototype__doFetch
  • DebugHTTPSServerPrototype__doFetch
  • WebCore::DebugHTTPServerPrototype__fetchCallback
  • 1 unknown/js code
  • jsc_llint_commonCallOp__llintOpWithMetadata__llintOpWithReturn__llintOp__commonOp__fn__fn__makeReturn__fn__fn__fn__666_callHelper__dispatch_LowLevelInterpreter64_asm_2535
  • jsc_llint_commonCallOp__llintOpWithMetadata__llintOpWithReturn__llintOp__commonOp__fn__fn__makeReturn__fn__fn__fn__666_callHelper__dispatch_LowLevelInterpreter64_asm_2535
  • jsc_llint_commonCallOp__llintOpWithMetadata__llintOpWithReturn__llintOp__commonOp__fn__fn__makeReturn__fn__fn__fn__684_callHelper__dispatch_LowLevelInterpreter64_asm_2535
  • llint_call_javascript
  • JSC::Interpreter::executeCall

Features: tsconfig, tsconfig_paths, http_server, jsc

Sentry Issue: BUN-D2G

@jclem jclem added the crash An issue that could cause a crash label Mar 11, 2025
@github-actions github-actions bot added macOS An issue that occurs on macOS runtime labels Mar 11, 2025
@jclem
Copy link
Author

jclem commented Mar 11, 2025

Ah, I think I misunderstood what server.fetch is used for!

@jclem jclem closed this as completed Mar 11, 2025
@RiskyMH RiskyMH reopened this Mar 12, 2025
@RiskyMH
Copy link
Member

RiskyMH commented Mar 12, 2025

I'm not sure what .fetch does right now, but it shouldn't crash

@RiskyMH RiskyMH removed the macOS An issue that occurs on macOS label Mar 12, 2025
@jclem
Copy link
Author

jclem commented Mar 12, 2025

I'm not sure what .fetch does right now, but it shouldn't crash

@RiskyMH I thought I could use it to test my server, which I've done in the past (I think?) when using Bun.serve({ fetch }). Looks like this happens when I'm using Bun.serve({ routes }), instead.

@alii
Copy link
Member

alii commented Mar 12, 2025

Simple reproduction:

const s = Bun.serve({
  port: 3000,
  routes: {
    '/': new Response('Hey'),
  },
});

const res = await s.fetch('http://localhost:3000/'); // also fails using `/` as url
console.log(await res.text());

@alii alii changed the title Crash when testing server Segfault when calling Server#fetch with .routes Mar 12, 2025
@alii alii added the confirmed bug We can reproduce this issue label Mar 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
confirmed bug We can reproduce this issue crash An issue that could cause a crash runtime
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants