nitrojs / nitrojs/nitro

Nitro with `bun` preset crashes upon closing a SSE (Server-Sent Events) connection

Open
#2,719 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug nuxt v2
Dominant language
TypeScript
Stars
11.2k
Forks
899
Avg merge
2d 24m
Merged PRs (30d)
40

Description

Environment

  • Operating System: Linux
  • Node Version: v20.12.2
  • Nuxt Version: 3.13.1
  • CLI Version: 3.13.1
  • Nitro Version: 2.9.7
  • Package Manager: bun@1.1.27
  • Builder: -
  • User Config: compatibilityDate, devtools, nitro
  • Runtime Modules: -
  • Build Modules: -

Reproduction

https://github.com/Anoesj/nitro-bun-sse-issue

[!NOTE]
I could not create a reproduction in Stackblitz/CodeSandbox, as I couldn't figure out how to use Bun there. Therefore, I created a repo instead. Make sure to read the README for reproduction steps.

Describe the bug

I ran into some crashes while using SSE and I think it has something to do with Nitro preset bun. I'm using a Nuxt application built with Nitro preset bun. I tried building the app in two different ways to check for differences, but both builds behave the same way:

  1. Using NITRO_PRESET=bun bun --bun run build
  2. Using the nitro.preset setting in nuxt.config.ts set to bun

The crash occurs when a frontend closes an SSE connection with the Nuxt app. It only crashes when using the bun Nitro preset. With the node-server preset, no issues arise. Also, when running the Nuxt app with bun --bun run dev with the Nitro bun preset, this crash does not occur upon closing an SSE connection.

Additional context

Bun revision: 1.1.27+267afa293
Platform: Linux 6.8.0-40-generic x86_64 x86_64.

If this is a Nuxt issue, feel free to transfer the issue to the Nuxt repository.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the reproduction repository and its README, following the listed build commands with the Nitro bun preset. Compare the behavior when an SSE connection closes under the bun preset with node-server and development mode; done means closing the connection no longer crashes the built application.

Written by the indexing model from the issue text.

Assessment

Tech stack
bun, nuxt, typescript
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.