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 using Bun.serve to serve results of a build #11896

Open
Atulin opened this issue Jun 15, 2024 · 0 comments
Open

Segfault when using Bun.serve to serve results of a build #11896

Atulin opened this issue Jun 15, 2024 · 0 comments
Labels
crash An issue that could cause a crash runtime windows An issue that only occurs on Windows

Comments

@Atulin
Copy link

Atulin commented Jun 15, 2024

How can we reproduce the crash?

The server code is very simple:

import { join } from "node:path";

const server = Bun.serve({
	port: 0,
	fetch(request) {
		let url = new URL(request.url).pathname;

		if (url.length === 0) {
			url = "index.html";
		}

		const filePath = join(import.meta.dir, "dist", url);
		const file = Bun.file(filePath);
		return new Response(file);
	},
	error() {
		return new Response(null, { status: 404 });
	},
});

console.log(`Serving at port ${server.port} url ${server.url.href}`);

the source directory is watched with Nodemon:

nodemon --watch pages --watch static -e ts,scss,md,html --exec 'bun build.mts'

which runs a more lengthy build script that places resulting files in dist directory.

Crash occurred when adding a new file to the source directory, having it built, and placed in the dist directory.

Relevant log output

MyProject\_Docs on  master [!?] via 🍞 v1.1.12 via  v21.6.2 
❯ bun run serve
$ bun serve.mts
Serving at port 9137 url http://localhost:9137/
============================================================
Bun v1.1.12 (43f0913c) Windows x64
Args: "C:\Users\Atulin\.bun\bin\bun.exe" "serve.mts"
Features: jsc abort_signal http_server tsconfig 
Builtins: "bun:main" "node:path" 
Elapsed: 22992ms | User: 78ms | Sys: 93ms
RSS: 117.37MB | Peak: 117.46MB | Commit: 0.19GB | Faults: 36732

panic(main thread): Segmentation fault at address 0xFFFFFFFFFFFFFFFF
oh no: Bun has crashed. This indicates a 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.1.12/wa143f0913AihghgEwv92b8x8hZ+96kXotglXwlzweu62xeg6zxew033G28vh2C6+hyFA2DD

error: script "serve" exited with code 3

Stack Trace (bun.report)

Bun v1.1.12 (43f0913) on windows x86_64 [AutoCommand]

Segmentation fault at address 0xFFFFFFFFFFFFFFFF

@Atulin Atulin added the crash An issue that could cause a crash label Jun 15, 2024
@github-actions github-actions bot added runtime windows An issue that only occurs on Windows labels Jun 15, 2024
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 runtime windows An issue that only occurs on Windows
Projects
None yet
Development

No branches or pull requests

1 participant