Skip to content

bun build --app panics with "Runtime file not found" for any custom Bake.Framework #32142

Closed

Description

@alii

What version of Bun is running?

1.3.14

What platform is your computer?

Darwin arm64 (macOS)

What steps can reproduce the bug?

mkdir bake-repro && cd bake-repro
mkdir pages

cat > pages/index.tsx <<'EOF'
export default function Home() { return "homepage"; }
EOF

cat > server-entry.ts <<'EOF'
export function render(req: Request, meta: any) {
  return new Response(String(meta.pageModule.default()));
}
export async function prerender(meta: any) {
  return { files: { "index.html": String(meta.pageModule.default()) } };
}
EOF

cat > client-entry.ts <<'EOF'
console.log("client loaded");
EOF

cat > bun.app.ts <<'EOF'
export default {
  app: {
    framework: {
      fileSystemRouterTypes: [{
        root: "pages",
        style: "nextjs-pages",
        serverEntryPoint: "./server-entry.ts",
        clientEntryPoint: "./client-entry.ts",
      }],
    },
  },
};
EOF

BUN_FEATURE_FLAG_EXPERIMENTAL_BAKE=1 bun build --app

What is the expected behavior?

dist/index.html is written from prerender.

What do you see instead?

Loading configuration
Bundling routes
Rendering routes
panic(main thread): Runtime file not found. This is an unexpected bug in Bun. Please file a bug report on GitHub.

The client chunk (dist/_bun/<hash>.js) is written, then bun crashes.

Additional information

The bundler only populates OutputFile.bake_extra when is_built_in_react is true:

src/bundler/linker_context/generateChunksInParallel.zig:739 —

if (!c.framework.?.is_built_in_react) break :brk .{};

For any custom Bake.Framework, every chunk's bake_extra.bake_is_runtime therefore stays false, so maybe_runtime_file_index is never assigned, and src/runtime/bake/production.zig:448 panics.

framework: "react" does not hit this panic (it fails earlier on missing react-server-dom-bun deps, which is expected). The dev server (Bun.serve with app: via the default-export-as-server convention) works fine for custom frameworks — only bun build --app is affected.

The fix is presumably to drop the is_built_in_react gate (or at minimum still set bake_is_runtime for custom frameworks).

Activity

  1. added
    bugSomething isn't working
    bake:prodspecifically for using bun kit to build to prod. consider using the `bundler` tag instead
    on Jun 11, 2026
  2. robobun commented on Jun 11, 2026

    @robobun
    Collaborator

    Reproduced: the custom framework repro panics with "Runtime file not found" after "Rendering routes" (exit 132, no dist/index.html).

    Fixed on main by #46021. On a build of 2a5cbbc the repro exits 0 and writes dist/index.html.

  3. added a commit that references this issue on Oct 20, 2026
    9b4284f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bake:prodspecifically for using bun kit to build to prod. consider using the `bundler` tag insteadbugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions