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

error: Could not resolve: "bun". Maybe you need to "bun install", then "panic" Internal assertion failure. #17874

Open
milkoqq opened this issue Mar 3, 2025 · 1 comment
Assignees
Labels
assertion failed Crashes in a build with assertions enabled bake:dev hot-reloading dev server for client+server applications confirmed bug We can reproduce this issue

Comments

@milkoqq
Copy link

milkoqq commented Mar 3, 2025

How can we reproduce the crash?

I just have a basic index.html with

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    Hello world
    <script type="module" src="./index.ts"></script>
  </body>
</html>

and an index.ts with

import { sql, serve } from "bun";
import homepage from "./index.html";

const server = Bun.serve({
  routes: {
    // ** HTML imports **
    // Bundle & route index.html to "/". This uses HTMLRewriter to scan the HTML for `<script>` and `<link>` tags, run's Bun's JavaScript & CSS bundler on them, transpiles any TypeScript, JSX, and TSX, downlevels CSS with Bun's CSS parser and serves the result.
    "/": homepage,
  },
  port: 3000,
  fetch(req) {
    return new Response("Bun!");
  },

  // Enable development mode for:
  // - Detailed error messages
  // - Hot reloading (Bun v1.2.3+ required)
  development: true,
});

console.log(Listening on ${server.url});

Running on Bun v1.2.4.. trying to just follow the "Fullstack Dev Server" example (https://bun.sh/docs/bundler/fullstack).. The weird thing is that I get this both on my Windows 10, and macOS.. I'm not very proficient with the CLI so yeah, I just don't know what to do:)

Running bun install gives this output:

bun install v1.2.4 (fd9a5ea6)

Checked 6 installs across 7 packages (no changes) [11.00ms]

Relevant log output

Bun v1.2.4 (fd9a5ea6) Windows x64
Windows v.win10_cu
CPU: sse42 avx avx2
Args: "C:\Users\theof\.bun\bin\bun.exe" "run" "index.ts"
Features: http_server jsc dev_server tsconfig
Builtins: "bun:main"
Elapsed: 5913ms | User: 31ms | Sys: 31ms
RSS: 0.24GB | Peak: 0.24GB | Commit: 0.23GB | Faults: 58467

panic(main thread): Internal assertion failure
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.2.4/wr1fd9a5eaEggg0B+y3jG+xZmi6+Vqw0qUoqm1S25stO4phuJ4vg6G2g38nBqnq2FA0eNrzzCtJLcpLzFFILC5OLSrJzM9TSEvMzCktSgUAiSkKPg

Stack Trace (bun.report)

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

panic: Internal assertion failure

Features: tsconfig, http_server, jsc, dev_server

Sentry Issue: BUN-CKE

@milkoqq milkoqq added the crash An issue that could cause a crash label Mar 3, 2025
@github-actions github-actions bot added runtime windows An issue that is known to occur on Windows labels Mar 3, 2025
@pfgithub
Copy link
Contributor

pfgithub commented Mar 3, 2025

The problem with your code is that index.html is importing index.js, which is the server file. You should give your frontend js a different file name. There's an example in the How to use with React section.

 


 

The bug in our code is that frontend code trying to import a javascript file importing an html file panics rather than giving a descriptive error.

Minimal Reproduction:

index.html:

<script type="module" src="./index.ts"></script>

index.ts:

import homepage from "./index.html";
console.log(homepage);
$> bun-debug index.html #, then navigate to localhost:3000
Listening on http://localhost:3000/
============================================================
Bun Debug v1.2.5 (42a826b9) macOS Silicon
macOS v15.3
Args: "bun-debug" "index.ts"
Features: http_server jsc dev_server
Builtins: "bun:main"
Elapsed: 1708ms | User: 70ms | Sys: 124ms
RSS: 0.30GB | Peak: 0.30GB | Commit: 1.07GB | Faults: 6675

panic(main thread): reached unreachable code
/Users/pfg/Dev/Node/bun/src/bun.zig:3425:43: 0x104897007 in assert (bun-debug)
        if (comptime Environment.isDebug) unreachable;
                                          ^
/Users/pfg/Dev/Node/bun/src/bit_set.zig:870:58: 0x10499de3f in isSet (bun-debug)
        if (comptime Environment.allow_assert) bun.assert(index < self.bit_length);
                                                         ^
/Users/pfg/Dev/Node/bun/src/bake/DevServer.zig:2709:37: 0x106389a17 in isFileCached (bun-debug)
            if (!g.stale_files.isSet(index)) {
                                    ^
/Users/pfg/Dev/Node/bun/src/bundler/bundle_v2.zig:3126:44: 0x10612bd0f in runResolutionForParseTask (bun-debug)
                if (dev_server.isFileCached(path.text, bake_graph)) |entry| {
                                           ^
/Users/pfg/Dev/Node/bun/src/bundler/bundle_v2.zig:3276:54: 0x10638585f in onParseTaskComplete (bun-debug)
            resolve_queue = runResolutionForParseTask(parse_result, this);
                                                     ^
/Users/pfg/Dev/Node/bun/src/bundler/bundle_v2.zig:5137:37: 0x1061270ab in onComplete (bun-debug)
        BundleV2.onParseTaskComplete(result, result.ctx);
                                    ^
/Users/pfg/Dev/Node/bun/src/bun.js/event_loop.zig:219:66: 0x105de3fc3 in wrap (bun-debug)
                @call(bun.callmod_inline, Callback, .{@as(*Type, @ptrCast(@alignCast(this.?)))});
                                                                 ^
/Users/pfg/Dev/Node/bun/src/bun.js/event_loop.zig:203:17: 0x105b63997 in run (bun-debug)
        callback(ctx.?);
                ^
/Users/pfg/Dev/Node/bun/src/bun.js/event_loop.zig:1139:28: 0x105712e6f in tickQueueWithCount__anon_558609 (bun-debug)
                    any.run();
                           ^
/Users/pfg/Dev/Node/bun/src/bun.js/event_loop.zig:1380:39: 0x1053a3f8b in tickWithCount (bun-debug)
        return this.tickQueueWithCount(virtual_machine, "tasks");
                                      ^

@pfgithub pfgithub added the confirmed bug We can reproduce this issue label Mar 3, 2025
@paperclover paperclover added bake:dev hot-reloading dev server for client+server applications assertion failed Crashes in a build with assertions enabled and removed crash An issue that could cause a crash windows An issue that is known to occur on Windows runtime labels Mar 3, 2025
@paperclover paperclover self-assigned this Mar 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
assertion failed Crashes in a build with assertions enabled bake:dev hot-reloading dev server for client+server applications confirmed bug We can reproduce this issue
Projects
None yet
Development

No branches or pull requests

3 participants