Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .bumpy/fix-nextjs-vercel-584.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@varlock/nextjs-integration": patch
---

bundle varlock into next-env-compat and skip CLI exec at runtime on serverless platforms
15 changes: 9 additions & 6 deletions packages/integrations/nextjs/src/next-env-compat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -329,9 +329,9 @@ export function loadEnvConfig(
const cleanEnv = { ...initialEnv };
delete cleanEnv.DEBUG_VARLOCK;
const varlockLoadedEnvStr = execSyncVarlock(`load --format json-full --env ${envFromNextCommand}`, {
showLogsOnError: true,
// Never use exitOnError here — we handle all error cases in the catch block
// below, including the "binary not found" case on serverless platforms.
// We handle all error display and exit logic ourselves in the catch block
// so we can silently defer on serverless platforms where the binary is missing.
showLogsOnError: false,
exitOnError: false,
env: cleanEnv as any,
});
Expand Down Expand Up @@ -362,10 +362,13 @@ export function loadEnvConfig(
process.exit(1);
}

// showLogsOnError already printed the formatted CLI output above,
// so we only add a short note here (err.message duplicates stderr)
// eslint-disable-next-line no-console
// For real errors (validation failures, etc.) show the CLI output
/* eslint-disable no-console */
const errAny = err as any;
if (errAny.stdout) console.log(errAny.stdout.toString());
if (errAny.stderr) console.error(errAny.stderr.toString());
console.error('[varlock] ⚠️ failed to load env — see error above');
/* eslint-enable no-console */

// In a build, we want to fail hard so broken env doesn't get deployed
if (!dev) {
Expand Down
Loading