Summary: Issue: Turbopack’s static analysis is not detecting direct process.env.MY_CUSTOM_VAR_1 and process.env.MY_CUSTOM_VAR_2 references in server-side code (API routes and server functions), causing these variables to be excluded from the TURBO_PLATFORM_ENV whitelist and unavailable at runtime.
Environment: Next.js: 16.0.3 Deployment: Vercel Production
Evidence: The TURBO_PLATFORM_ENV whitelist remains stuck with only 6 variables despite multiple fresh builds: “TURBO_PLATFORM_ENV”:“VAR_A,VAR_B,VAR_C,VAR_D,VAR_E,VAR_F”
Missing variables: MY_CUSTOM_VAR_1, MY_CUSTOM_VAR_2
Code references: All variables are referenced in server-side API routes and utility functions using direct syntax: process.env.MY_CUSTOM_VAR_1 (no dynamic construction)
What we’ve tried:
- Clearing build cache (manually and via VERCEL_FORCE_NO_BUILD_CACHE=1)
- Multiple fresh deployments
- Removing variables from next.config.ts
- Direct references only (no bracket notation or dynamic construction)
- Verifying variables are set correctly in Vercel dashboard
Pattern observation: Some environment variables (e.g., VAR_A) are correctly detected and whitelisted, but others (e.g., MY_CUSTOM_VAR_1) are not, despite both being:
- Set in Vercel environment variables
- Directly referenced in server-side code
- Used in the same files
This suggests a potential bug in Turbopack’s pattern matching or variable name handling (possibly related to name length, prefix patterns, or underscore count).
Anybody understand why Turbopack’s static analysis fails to detect these specific variable references ?
Thx,
Fabrice