fix(build): keep the server logger out of client bundles

The production webpack build failed with UnhandledSchemeError: client
components imported @/lib/logger, which binds pino, AsyncLocalStorage
(node:async_hooks), node:crypto and node:fs — and validates server env on
import. The UI fixture aliased those modules, so the harness and tests
never hit it.

- add src/lib/browser-log.ts: browser-safe logger with the same interface;
  errors are forwarded to /api/diagnostics/errors via reportBrowserError
- guard src/lib/logger.ts with server-only and drop its now-dead browser
  branches
- switch the 11 client components/hooks to @/lib/browser-log

Verified with the Dockerfile's production build (pnpm run build) and the
full vitest suite.
This commit is contained in:
openhands committed 2026-10-17 17:49:53 +02:00
1 parent fb470123c3
commit c15177a52e
13 files changed
+71 -42

No files matched your search

+1 -1
View File
@@ -4,7 +4,7 @@ import { useRouter } from "next/navigation";
import { useTranslations } from "next-intl";
import { useRef, useState, useTransition } from "react";
import { toast } from "sonner";
import { logger } from "@/lib/logger";
import { logger } from "@/lib/browser-log";
import type { ActionResult } from "@/lib/safe-action-shared";
interface UseServerActionOptions {