Debugging
Goal: stop on a line of server code, see why a page differs between server and browser, and see what the build did.
- Attach a debugger to the server.
hamur dev --inspectstarts each server process of the dev server with Bun's inspector, so a breakpoint in a loader, handler, middleware or plugin stops a request. The address is printed afterLocal:and is alwaysws://127.0.0.1:9229/hamur; VS Code attaches to it. - Read the report of a hydration mismatch. The terminal prints
[hamur] hydration mismatch in <component> at <path>with the route, and the page shows a panel with the server's and the client's markup.devServer.hydrationMismatchis"overlay"by default,"console"for the lines alone andfalsefor none. - Ask the build what it did.
debugprints a line per build hook, per template written and per module that changed an option;--debugon a command also prints stacks and writes the build's virtual modules to.hamur/virtual/:
import { defineConfig } from "hamur"
export default defineConfig({
framework: "react",
devServer: { hydrationMismatch: "overlay" },
debug: { hooks: true },
})
- These commands cover the rest.
hamur routesprints the route table with the file of each route,hamur info --markdownprints versions and paths for an issue,hamur generate --debug-prerenderstops at the first page that fails to prerender with its path and mapped stack, andhamur build --debugexplains a failing build:
hamur dev --inspect
hamur routes
hamur info --markdown
hamur generate --debug-prerender
hamur build --debug
The browser side is debugged with the browser's own tools: the client bundle carries source maps.
See also: Debugging, Dev server, Devtools, CLI.