Turbopack: Add TransientEnvMap to avoid persisting env vars in cache (#90526)
### What? Introduces a new `TransientEnvMap` type and changes `ProcessEnv::read_all()` to return `Vc<TransientEnvMap>` instead of `Vc<EnvMap>`. ### Why? `EnvMap` uses default (auto) serialization, which means all process environment variables — including secrets like API keys and tokens — could be written to the persistent disk cache. `TransientEnvMap` uses `serialization = "none"`, ensuring env vars are never persisted and must always be read fresh from the process environment on cache restore. ### How? - Added `TransientEnvMap` in `turbo-tasks-env/src/lib.rs`: a transparent wrapper around `FxIndexMap<RcStr, RcStr>` with `serialization = "none"` - Changed `ProcessEnv::read_all()` trait method return type from `Vc<EnvMap>` → `Vc<TransientEnvMap>` - Updated all 7 implementations of `ProcessEnv::read_all()` (`EnvMap`, `CommandLineProcessEnv`, `CustomProcessEnv`, `FilterProcessEnv`, `DotenvProcessEnv`, `TryDotenvProcessEnv`, `EmbeddableProcessEnv`) - Updated helper functions (`case_insensitive_read`, `to_uppercase_map`, `common_node_env`) to work with `TransientEnvMap` - `EnvMap` (serializable) is kept for config-derived env maps like `next.config.js` env and `edge_env`
Showing
Please
register
or
sign in
to comment