Debugging
Chrome DevTools MCP
Section titled “Chrome DevTools MCP”Use chrome-devtools-mcp to let Claude inspect browser state directly.
# Installpnpm dlx @anthropic-ai/chrome-devtools-mcpClaude can then:
- Inspect console logs/errors
- View network requests
- Read DOM state
- Check localStorage/cookies
- Debug React component state
Cloudflare
Section titled “Cloudflare”Wrangler Tail (Live Logs)
Section titled “Wrangler Tail (Live Logs)”# Stream live logs from Workerswrangler tail
# Filter by statuswrangler tail --status error
# Filter by search termwrangler tail --search "userId"
# JSON output for parsingwrangler tail --format jsonD1 Debugging
Section titled “D1 Debugging”# Query D1 directlywrangler d1 execute DB_NAME --command "SELECT * FROM users LIMIT 5"
# Export for inspectionwrangler d1 export DB_NAME --output dump.sql
# Local D1 (dev)wrangler d1 execute DB_NAME --local --command "SELECT * FROM users"Workers Logs (Dashboard)
Section titled “Workers Logs (Dashboard)”dash.cloudflare.com → Workers → Your Worker → Logs
- Real-time log stream
- Filter by time/status
- Request traces with timing
Request Logging Middleware
Section titled “Request Logging Middleware”import { logger } from "hono/logger";
app.use("*", logger());Custom Debug Middleware
Section titled “Custom Debug Middleware”app.use("*", async (c, next) => { const start = Date.now(); await next(); console.log(`${c.req.method} ${c.req.path} - ${c.res.status} (${Date.now() - start}ms)`);});Error Handling
Section titled “Error Handling”app.onError((err, c) => { console.error(`${c.req.method} ${c.req.path}:`, err); return c.json({ error: err.message }, 500);});Drizzle
Section titled “Drizzle”Query Logging
Section titled “Query Logging”import { drizzle } from "drizzle-orm/d1";
const db = drizzle(env.DB, { logger: true // logs all queries});Custom Logger
Section titled “Custom Logger”const db = drizzle(env.DB, { logger: { logQuery(query, params) { console.log("Query:", query); console.log("Params:", params); }, },});TanStack Query
Section titled “TanStack Query”DevTools
Section titled “DevTools”import { ReactQueryDevtools } from "@tanstack/react-query-devtools";
function App() { return ( <QueryClientProvider client={queryClient}> <YourApp /> <ReactQueryDevtools initialIsOpen={false} /> </QueryClientProvider> );}Query Logging
Section titled “Query Logging”const queryClient = new QueryClient({ defaultOptions: { queries: { onError: (err) => console.error("Query error:", err), }, mutations: { onError: (err) => console.error("Mutation error:", err), }, },});Better Auth
Section titled “Better Auth”Debug Mode
Section titled “Debug Mode”export const auth = betterAuth({ logger: { disabled: false, level: "debug", // error | warn | info | debug },});Session Inspection
Section titled “Session Inspection”// Server-sideconst session = await auth.api.getSession({ headers });console.log("Session:", session);
// Client-sideconst { data } = authClient.useSession();console.log("Client session:", data);Network Debugging
Section titled “Network Debugging”Fetch Interceptor (Client)
Section titled “Fetch Interceptor (Client)”const originalFetch = window.fetch;window.fetch = async (...args) => { console.log("Fetch:", args[0]); const res = await originalFetch(...args); console.log("Response:", res.status); return res;};Environment Tips
Section titled “Environment Tips”# Local dev with remote D1wrangler dev --remote
# Local dev with local D1wrangler dev --local
# Check bindingswrangler whoamiwrangler d1 list