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

Bun Crashes when changing client.js javascript code. How to disable HMR javascript injection on the HTML page? #18003

Open
dicinohit opened this issue Mar 8, 2025 · 2 comments
Labels
crash An issue that could cause a crash windows An issue that is known to occur on Windows

Comments

@dicinohit
Copy link

dicinohit commented Mar 8, 2025

How can we reproduce the crash?

I have a server.js importing and serving a static HTML homepage that uses an ES module called client.js. When I change the client code, Bun crashes.

By the way, I do not like that you guys inject JavaScript code for the "hmr" functionality. I don't need any of this HMR stuff. In the browser network information, I see a pending socket connection. How can I disable this HMR code injection? I see no documentation about it anywhere in your docs. It's annoying that you do code injection without any docs or mention of how to disable this.

I just started coding this, so the source code is very small... On the Bun server.js:

import homepage from "./index.html";

Bun.serve({
static: {
"/": homepage,
},
port: 3000
}

The HTML has this javascript " <script type="module" src="client.js"></script>". The client code is just a class.

I guess this error message is because the port was not freed when it crashed. So, I don't think this log helps much:

Relevant log output

Bun.serve({
         ^
error: Failed to start server. Is port 3000 in use?
 syscall: "listen",
   errno: 0,
    code: "EADDRINUSE"

      at C:\Dev\Projects\snamba\server.js:18:5

Stack Trace (bun.report)

Bun v1.2.4 (fd9a5ea) on windows x86_64 [AutoCommand]

panic: Internal assertion failure

Features: tsconfig, tsconfig_paths, process_dlopen, Bun.stderr, Bun.stdout, bunfig, http_server, jsc, dev_server

Sentry Issue: BUN-D41

@dicinohit dicinohit added the crash An issue that could cause a crash label Mar 8, 2025
@github-actions github-actions bot added the windows An issue that is known to occur on Windows label Mar 8, 2025
@kravetsone
Copy link

U can disable HMR with `development: {hmr: false} at Bun.serve option

@dicinohit
Copy link
Author

dicinohit commented Mar 8, 2025

Great. Removing HMR helped, and Bun is not crashing when changing the client code because it stopped doing hot reloading.

I suggest setting "hmr: false" as the default until HMR is production-ready because it is not working now even with a simple code setup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crash An issue that could cause a crash windows An issue that is known to occur on Windows
Projects
None yet
Development

No branches or pull requests

2 participants