From abb8c50f233a0a0877af3de0bfb84179e74efb08 Mon Sep 17 00:00:00 2001 From: Replit Agent Date: Thu, 19 Mar 2026 21:52:24 +0000 Subject: [PATCH] fix: replace import.meta.url with process.cwd() in testkit.ts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit import.meta.url is undefined when esbuild bundles to CJS format (format: 'cjs' in build.ts). fileURLToPath(undefined) throws ERR_INVALID_ARG_TYPE which crashed the production server on startup. Fix: drop the _dirname derivation entirely and resolve TIMMY_TEST_PLAN.md relative to process.cwd(), which is always the workspace root in both: - dev: tsx runs from workspace root - production: pnpm --filter ... run start runs from workspace root Also removes the now-unused 'dirname' and 'fileURLToPath' imports. Verified: rebuilt dist/index.cjs — 0 import.meta.url references remain. GET /api/testkit/plan returns HTTP 200 from the production bundle. --- artifacts/api-server/src/routes/testkit.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/artifacts/api-server/src/routes/testkit.ts b/artifacts/api-server/src/routes/testkit.ts index 0ec19e6..9683b35 100644 --- a/artifacts/api-server/src/routes/testkit.ts +++ b/artifacts/api-server/src/routes/testkit.ts @@ -1,7 +1,6 @@ import { Router, type Request, type Response } from "express"; import { readFileSync } from "fs"; -import { resolve, dirname } from "path"; -import { fileURLToPath } from "url"; +import { resolve } from "path"; const router = Router(); @@ -1105,8 +1104,7 @@ if [[ "\$FAIL" -gt 0 ]]; then exit 1; fi * Returns TIMMY_TEST_PLAN.md verbatim as text/markdown. * Path resolves from the project root regardless of cwd. */ -const _dirname = dirname(fileURLToPath(import.meta.url)); -const PLAN_PATH = resolve(_dirname, "../../../../TIMMY_TEST_PLAN.md"); +const PLAN_PATH = resolve(process.cwd(), "TIMMY_TEST_PLAN.md"); router.get("/testkit/plan", (_req: Request, res: Response) => { let content: string;