From 81c43b45fb0470fc5a8aa7d6c91fae36ba6a231f Mon Sep 17 00:00:00 2001 From: diegosouzapw Date: Wed, 18 Mar 2026 15:08:57 -0300 Subject: [PATCH] fix: pino-abstract-transport missing in Docker + responses worker crash + lock sync MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - fix(docker): copy pino-abstract-transport and pino-pretty explicitly in runner-base stage — Next.js standalone trace omits them, causing 'Cannot find module pino-abstract-transport' crash on startup (#449) - fix(responses): remove initTranslators() call from /v1/responses route — bootstrapping translator registry from a Next.js Route Handler worker caused 'the worker has exited' uncaughtException on Codex CLI requests. Translators are already bootstrapped server-side via open-sse (#450) - chore: include package-lock.json in commit (was being left behind on version bumps, causing npm ci to install inconsistent deps in Docker) --- Dockerfile | 4 ++++ package-lock.json | 4 ++-- src/app/api/v1/responses/route.ts | 21 +++++++++------------ 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/Dockerfile b/Dockerfile index cc36e7fd6a..96bcb73e76 100644 --- a/Dockerfile +++ b/Dockerfile @@ -32,6 +32,10 @@ COPY --from=builder /app/.next/static ./.next/static COPY --from=builder /app/.next/standalone ./ # Explicitly copy @swc/helpers — not always traced by standalone output but needed at runtime COPY --from=builder /app/node_modules/@swc/helpers ./node_modules/@swc/helpers +# Explicitly copy pino transport dependencies — pino spawns a worker that requires +# pino-abstract-transport at runtime; Next.js standalone trace does not capture it (#449) +COPY --from=builder /app/node_modules/pino-abstract-transport ./node_modules/pino-abstract-transport +COPY --from=builder /app/node_modules/pino-pretty ./node_modules/pino-pretty COPY --from=builder /app/scripts/run-standalone.mjs ./run-standalone.mjs COPY --from=builder /app/scripts/runtime-env.mjs ./runtime-env.mjs COPY --from=builder /app/scripts/bootstrap-env.mjs ./bootstrap-env.mjs diff --git a/package-lock.json b/package-lock.json index c0482c2ad1..3535e36063 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "omniroute", - "version": "2.7.0", + "version": "2.7.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "omniroute", - "version": "2.7.0", + "version": "2.7.2", "hasInstallScript": true, "license": "MIT", "workspaces": [ diff --git a/src/app/api/v1/responses/route.ts b/src/app/api/v1/responses/route.ts index 2588bc900f..809ed1a41f 100644 --- a/src/app/api/v1/responses/route.ts +++ b/src/app/api/v1/responses/route.ts @@ -1,16 +1,14 @@ import { CORS_ORIGIN } from "@/shared/utils/cors"; import { handleChat } from "@/sse/handlers/chat"; -import { initTranslators } from "@omniroute/open-sse/translator/index.ts"; -let initialized = false; - -async function ensureInitialized() { - if (!initialized) { - await initTranslators(); - initialized = true; - console.log("[SSE] Translators initialized for /v1/responses"); - } -} +// NOTE: We do NOT call initTranslators() here — the translator registry is +// bootstrapped at module level inside open-sse/translator/index.ts when it +// is first imported. Calling it again from a Next.js Route Handler caused a +// "the worker has exited" uncaughtException crash on Codex CLI requests (#450) +// because the dynamic import runs in a Next.js server worker context where +// certain Node APIs used by the translator bootstrap are not available. +// The translators are always initialized via the open-sse side (chatCore), +// so /v1/responses just delegates to handleChat which handles everything. export async function OPTIONS() { return new Response(null, { @@ -24,9 +22,8 @@ export async function OPTIONS() { /** * POST /v1/responses - OpenAI Responses API format - * Now handled by translator pattern (openai-responses format auto-detected) + * Handled by the unified chat handler (openai-responses format auto-detected). */ export async function POST(request) { - await ensureInitialized(); return await handleChat(request); }