Skip to content

Debugging

Goal: stop on a line of server code, see why a page differs between server and browser, and see what the build did.

  1. Attach a debugger to the server. hamur dev --inspect starts 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 after Local: and is always ws://127.0.0.1:9229/hamur; VS Code attaches to it.
  2. 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.hydrationMismatch is "overlay" by default, "console" for the lines alone and false for none.
  3. Ask the build what it did. debug prints a line per build hook, per template written and per module that changed an option; --debug on a command also prints stacks and writes the build's virtual modules to .hamur/virtual/:
ts
import { defineConfig } from "hamur"

export default defineConfig({
  framework: "react",
  devServer: { hydrationMismatch: "overlay" },
  debug: { hooks: true },
})
  1. These commands cover the rest. hamur routes prints the route table with the file of each route, hamur info --markdown prints versions and paths for an issue, hamur generate --debug-prerender stops at the first page that fails to prerender with its path and mapped stack, and hamur build --debug explains a failing build:
sh
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.