From 5b8ab33888d98ca003ce17f68eb22c2fd09f92f3 Mon Sep 17 00:00:00 2001 From: Amruth Pillai Date: Fri, 3 Jul 2026 20:55:41 +0200 Subject: [PATCH] fix: rethrow non-ENOENT errors when loading .env --- packages/env/src/server.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/env/src/server.ts b/packages/env/src/server.ts index d97bc1105..d0278b106 100644 --- a/packages/env/src/server.ts +++ b/packages/env/src/server.ts @@ -7,11 +7,11 @@ const workspaceRoot = findWorkspaceRoot(); if (workspaceRoot) { try { - // ponytail: native stand-in for dotenv. loadEnvFile throws when .env is absent - // (e.g. production with injected env), and existing process.env still wins — so just tolerate a miss. + // Native stand-in for dotenv: existing process.env still wins over file values. process.loadEnvFile(join(workspaceRoot, ".env")); - } catch { - // no .env file — rely on the ambient process environment + } catch (error) { + // A missing .env is expected (e.g. production with injected env); anything else is a real problem. + if (!(error instanceof Error && "code" in error && error.code === "ENOENT")) throw error; } }