Skip to content

Commit 5c5f59e

Browse files
committed
Guard argv access in shared env
1 parent 74df273 commit 5c5f59e

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

common/src/env.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
import { clientEnvSchema, clientProcessEnv } from './env-schema'
22

3-
// Only log environment in non-production
4-
if (process.env.NEXT_PUBLIC_CB_ENVIRONMENT !== 'prod') {
3+
// Only log environment in non-production, and not during OSC detection
4+
// Check process.argv since it's more reliable than env vars in spawned processes
5+
const isOscDetect =
6+
typeof process !== 'undefined' &&
7+
Array.isArray(process.argv) &&
8+
process.argv.some(arg => arg.includes('--internal-osc-detect'))
9+
if (
10+
process.env.NEXT_PUBLIC_CB_ENVIRONMENT !== 'prod' &&
11+
!isOscDetect
12+
) {
513
console.log('Using environment:', process.env.NEXT_PUBLIC_CB_ENVIRONMENT)
614
}
715

0 commit comments

Comments
 (0)