Bun Run Dev Crashed When Refresh Web Page.
Introduction
As a ReactJS beginner, I encountered a frustrating issue with the Bun development server. When I ran bun run dev
on a fresh React project and refreshed the web page, the Bun server crashed. The Firefox DevTool displayed an NS_ERROR_CONNECTION_REFUSED
error. In this article, I will walk you through the steps I took to reproduce the issue, the command-line history, and the relevant log output.
Reproducing the Crash
To reproduce the crash, I followed these steps:
- Created a new React project using
bun init
with the default template. - Ran
bun install
to install the required dependencies. - Ran
bun run dev
to start the development server. - Opened the web page in Firefox and refreshed the page.
However, I was unable to reproduce the crash consistently. The issue seemed to be intermittent.
Command-Line History
Here is the command-line history:
MeteorImpact D:\....\web mkdir reactjs
Directory: D:\Project\web
Mode LastWriteTime Length Name
---- ------------- ------ ----
d---- 2025-04-22 23:06 reactjs
MeteorImpact D:\....\web cd .\reactjs\
MeteorImpact D:\....\reactjs bun init
✓ Select a project template: React
✓ Select a React template: Default (blank)
+ bunfig.toml
+ package.json
+ tsconfig.json
+ README.md
+ .gitignore
+ src/index.tsx
+ src/App.tsx
+ src/index.html
+ src/index.css
+ src/APITester.tsx
+ src/react.svg
+ src/frontend.tsx
+ src/logo.svg
✨ New project configured!
Development - full-stack dev server with hot reload
bun dev
Static Site - build optimized assets to disk (no backend)
bun run build
Production - serve a full-stack production build
bun start
Happy bunning! 🐇
MeteorImpact D:\....\reactjs bun install
bun install v1.2.5 (013fdddc)
Checked 10 installs across 11 packages (no changes) [30.00ms]
MeteorImpact D:\....\reactjs bun run dev
$ bun --hot src/index.tsx
🚀 Server running at http://localhost:3000/
Bundled page in 628ms: src/index.html
============================================================
Bun v1.2.5 (013fdddc) Windows x64
Windows v.win11_dt
CPU: sse42 avx avx2
Args: "C:\Users\meteo\.bun\bin\bun.exe" "--hot" "src/index.tsx"
Features: bunfig http_server jsc dev_server tsconfig(6) tsconfig_paths(6)
Builtins: "bun:main"
Elapsed: 7536ms | User: 296ms | Sys: 171ms
RSS: 0.20GB | Peak: 0.20GB | Commit: 0.34GB | Faults: 50645
panic(main thread): Internal assertion failure
oh no: Bun has crashed. This indicates bug in Bun, not your code.
To send a redacted crash report to Bun's team,
please file a GitHub issue using the link below:
https://bun.report/1.2.5/wa1013fdddMgkg0B+34jG+xZ0w8mT4m41Y2lvyX+t5wUgv+5S6h4vO4yhvJqxi6GA0eNrzzCtJLcpLzFFILC5OLSrJzM9TSEvMzCktSgUAiSkKPg
error: script "dev" exited with code 134
Environment
Here is the environment information:
MeteorImpact D:\....\reactjs $PSVersionTable
Name Value
---- -----
PSVersion 7.5.0
PSEdition Core
GitCommitId 7.5.0
OS Microsoft Windows 10.0.26100
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Relevant Log Output
There is no relevant log output to display.
Stack Trace (bun.report)
Here is the stack trace from bun.report:
Bun v1.2.5 ([`013fddd`](<https://github.com/oven-sh/bun/tree/013fdddc6ed18bc849614ccb37a296fa0f69a5db>)) on windows x86_64 [AutoCommand]
**panic**: Internal assertion failure
- [`bundle_v2.zig:1283`](<https://github.com/oven-sh/bun/blob/013fdddc6ed18bc849614ccb37a296fa0f69a5db/src/bundler/bundle_v2.zig#L1283>): `enqueueEntryPoints`
- [`DevServer.zig:2645`](<https://github.com/oven-sh/bun/blob/013fdddc6ed18bc849614ccb37a296fa0f69a5db/src/bake/DevServer.zig#L2645>): `startNextBundleIfPresent`
- [`DevServer.zig:2030`](<https://github.com/oven-sh/bun/blob/013fdddc6ed18bc849614ccb37a296fa0f69a5db/src/bake/DevServer.zig#L2030>): `finalizeBundle`
- [`bundle_v2.zig:2810`](<https://github.com/oven-sh/bun/blob/013fdddc6ed18bc849614ccb37a296fa0f69a5db/src/bundler/bundle_v2.zig#L2810>): `finishFromBakeDevServer`
- [`memory_allocator.zig:31`](<https://github.com/oven-sh/bun/blob/013fdddc6ed18bc849614ccb37a296fa0f69a5db/src/allocators/memory_allocator.zig#L31>): `mimalloc_free`
- [`memory_allocator.zig:31`](<https://github.com/oven-sh/bun/blob/013fdddc6ed18bc849614ccb37a296fa0f69a5db/src/allocators/memory_allocator.z#L31>): `mimalloc_free`
- [`event_loop.zig:1388`](<https://github.com/oven-sh/bun/blob/013fdddc6ed18bc849614ccb37a296fa0f69a5db/src/bun.js/event_loop.zig#L1388>): `tickConcurrent`
- [`javascript.zig:1261`](<https://github.com/oven-sh/bun/blob/013fdddc6ed18bc849614ccb37a296fa0f69a5db/src/bun.js/javascript.zig#L1261>): `handlePendingInternalPromiseRejection`
Features: transpiler\_cache, tsconfig, tsconfig\_paths, process\_dlopen, Bun.stderr, Bun.stdout, bunfig, dotenv, http\_server, jsc, dev\_server
Conclusion
In conclusion, I was unable to reproduce the crash consistently, but I was able to capture the relevant log output and stack trace from bun.report. The issue seems to be related to an internal assertion failure in the Bun development server. If you are experiencing similar issues, please file a GitHub issue using the link provided in the stack trace.
Introduction
In our previous article, we explored the issue of Bun run dev crashing when refreshing the web page. We walked through the steps to reproduce the issue, the command-line history, and the relevant log output. In this article, we will answer some frequently asked questions (FAQs) related to this issue.
Q: What is Bun and why is it crashing?
A: Bun is a new development server that aims to provide a fast and efficient way to develop web applications. It is built on top of the Zig programming language and provides a number of features such as hot reloading, code splitting, and more. When Bun crashes, it is usually due to an internal assertion failure, which indicates a bug in the Bun code.
Q: What are the symptoms of the crash?
A: The symptoms of the crash include:
- The Bun development server crashing when refreshing the web page
- The Firefox DevTool displaying an
NS_ERROR_CONNECTION_REFUSED
error - The Bun log output displaying an internal assertion failure
Q: How can I reproduce the crash?
A: To reproduce the crash, follow these steps:
- Create a new React project using
bun init
with the default template. - Run
bun install
to install the required dependencies. - Run
bun run dev
to start the development server. - Open the web page in Firefox and refresh the page.
Q: Why is the crash intermittent?
A: The crash is intermittent because it is related to an internal assertion failure in the Bun code. This failure can occur randomly, making it difficult to reproduce consistently.
Q: What are the possible causes of the crash?
A: The possible causes of the crash include:
- A bug in the Bun code
- A conflict with other development tools or libraries
- A problem with the system configuration or environment
Q: How can I fix the crash?
A: To fix the crash, you can try the following:
- Update Bun to the latest version
- Check for conflicts with other development tools or libraries
- Adjust the system configuration or environment to resolve any issues
Q: What should I do if I encounter the crash?
A: If you encounter the crash, follow these steps:
- Check the Bun log output for any error messages or internal assertion failures.
- File a GitHub issue using the link provided in the stack trace.
- Provide any relevant information or logs to help the Bun team diagnose the issue.
Q: Is this issue specific to React or can it occur with other frameworks?
A: This issue can occur with other frameworks as well, not just React. However, the symptoms and behavior may vary depending on the specific framework and configuration.
Q: Will the Bun team fix this issue?
A: Yes, the Bun team is actively working to fix this issue and provide a stable and reliable development experience. If you encounter the crash, please file a GitHub issue and provide any relevant information to help the team diagnose and fix the issue.