fix(turbopack): drop pino logger from berth-range — async_hooks leaked to client bundle
Same client-server boundary bug class as adf4e2b. berth-range.ts
imported `logger` (-> request-context.ts -> node:async_hooks) for
two debug/warn calls. external-eoi-upload-dialog.tsx is a client
component and imports formatBerthRange — Turbopack chunked
async_hooks into the client bundle and crashed with:
Code generation for chunk item errored
Caused by: the chunking context (unknown) does not support
external modules (request: node:async_hooks)
Surface was the entire interest detail page on every viewport: dev
shell rendered the Turbopack overlay instead of the actual UI, so
the planned visual audit couldn't take any meaningful screenshots.
Replaced logger.debug + logger.warn with a single console.warn that
summarises non-canonical moorings. console.warn is safe in both
server and client contexts and the formatter's failure mode is
non-critical (verbatim passthrough — no data loss).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -20,7 +20,12 @@
|
||||
* (plan §1).
|
||||
*/
|
||||
|
||||
import { logger } from '@/lib/logger';
|
||||
// Note: this module is imported by client components (e.g. the EOI
|
||||
// upload dialog), so we deliberately avoid `@/lib/logger` — that file
|
||||
// pulls in `request-context.ts` which uses `node:async_hooks`, an
|
||||
// import Turbopack can't include in a client bundle. `console.warn`
|
||||
// works on both client and server and is more than enough for a
|
||||
// formatter warning.
|
||||
|
||||
const CANONICAL = /^([A-Z]+)(\d+)$/;
|
||||
|
||||
@@ -61,19 +66,17 @@ export function formatBerthRange(mooringNumbers: readonly string[]): string {
|
||||
const p = tryParse(m);
|
||||
if (p) parsed.push(p);
|
||||
else {
|
||||
// Per-mooring is debug to keep logs quiet when archived rows
|
||||
// (with " (archived)" / " (deleted)" suffixes) flow through a
|
||||
// bundle; the single summary `warn` below makes the situation
|
||||
// observable without spamming.
|
||||
logger.debug({ mooring: m }, 'formatBerthRange: non-canonical mooring; passing through');
|
||||
// Per-mooring debug intentionally omitted to keep noise down;
|
||||
// the single summary warn below makes the situation observable.
|
||||
passthrough.push(m);
|
||||
}
|
||||
}
|
||||
|
||||
if (passthrough.length > 0) {
|
||||
logger.warn(
|
||||
{ count: passthrough.length, samples: passthrough.slice(0, 3) },
|
||||
'formatBerthRange: non-canonical moorings passed through (verbatim, not range-compressed)',
|
||||
console.warn(
|
||||
'formatBerthRange: %d non-canonical moorings passed through (samples: %o)',
|
||||
passthrough.length,
|
||||
passthrough.slice(0, 3),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user