Repository navigation
fix(dev): let a restarted fork reload changed .env values - #1592
Conversation
Editing `.env` restarts Nuxt in a new process, but the fork inherited the parent's `process.env`, including the values the old `.env` had put there. c12 only overwrites variables it set itself and keeps that record per process, so in the fork the stale values looked like shell variables and won: a changed value was never picked up, and a removed one stayed. Drop the variables c12 set from `.env` before forking, so the fork reads the files afresh. Variables from the shell are untouched. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (2)
Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review. 📝 WalkthroughWalkthroughThe dev pool now removes registered dotenv keys from the environment passed to forked processes. An end-to-end test checks that dotenv updates change the returned marker, the shell-provided value remains unchanged, and the server PID changes after each update. Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~12 minutes Merge Risk: ⚪ Minimal · up to Restarted dev forks now reload changed .env values while keeping shell-provided variables. No merge-blocking risk was identified. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The change is limited to development-server restarts and preserves shell-provided settings in the inspected implementation. No introduced security issue was established. Remaining uncertainty concerns environment-ownership compatibility and settings modified by third-party code. Retained concerns Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
commit: |
CLI benchmark
Full report
|
| Setting | Value |
|---|---|
| Baseline | ref:f140924fb88992febb831316ac01bce275609336 (v4.0.0-alpha.1) |
| Head | local packages/nuxt-cli at 59414c4 (v4.0.0-alpha.1) |
| Node | v24.21.0 |
| OS | Linux 6.17.0 (kernel 6.17.0-1022-azure) |
| CPU | AMD EPYC 9V74 80-Core Processor x 4 |
| Memory | 15.6 GB |
| Load average at start | 2.29, 0.63, 0.22 |
| Run started | 2026-10-05T14:31:05.637Z |
Cold CLI startup
Median of 15 interleaved runs per command, one warmup discarded.
| Command | baseline v4.0.0-alpha.1 median | head v4.0.0-alpha.1 median | Delta | baseline v4.0.0-alpha.1 min / p95 | head v4.0.0-alpha.1 min / p95 |
|---|---|---|---|---|---|
nuxt --version |
53 ms | 54 ms | +2.5% | 51 ms / 55 ms | 51 ms / 56 ms |
nuxt --version (first output byte) |
49 ms | 50 ms | +2.9% | 47 ms / 52 ms | 47 ms / 52 ms |
nuxt --help |
107 ms | 109 ms | +1.7% | 104 ms / 116 ms | 105 ms / 113 ms |
nuxt --help (first output byte) |
103 ms | 104 ms | +1.7% | 99 ms / 111 ms | 101 ms / 108 ms |
nuxt dev --help |
84 ms | 84 ms | -0.4% | 80 ms / 88 ms | 80 ms / 88 ms |
nuxt dev --help (first output byte) |
80 ms | 80 ms | -0.5% | 76 ms / 84 ms | 76 ms / 84 ms |
nuxt <unknown-command> (no-op) |
117 ms | 116 ms | -0.2% | 111 ms / 120 ms | 111 ms / 120 ms |
nuxt <unknown-command> (no-op) (first output byte) |
112 ms | 111 ms | -0.4% | 106 ms / 115 ms | 106 ms / 115 ms |
Module load cost
Counted with a module.registerHooks load hook, compile cache disabled. Counts every JS module actually evaluated on that code path (native addons excluded). Built-ins loaded after bootstrap are counted separately, including the internal modules they load.
| Command | baseline v4.0.0-alpha.1 modules | head v4.0.0-alpha.1 modules | Delta | baseline v4.0.0-alpha.1 source bytes | head v4.0.0-alpha.1 source bytes | Delta | baseline v4.0.0-alpha.1 built-ins | head v4.0.0-alpha.1 built-ins | Delta |
|---|---|---|---|---|---|---|---|---|---|
nuxt --version |
35 | 35 | 0.0% | 297.8 kB | 297.8 kB | 0.0% | 27 | 27 | 0.0% |
nuxt --help |
134 | 135 | +0.7% | 842.5 kB | 847.4 kB | +0.6% | 87 | 87 | 0.0% |
nuxt dev --help |
63 | 64 | +1.6% | 453.0 kB | 455.3 kB | +0.5% | 87 | 87 | 0.0% |
Install footprint and published tarball
Each version installed on its own into an empty project with nothing but @nuxt/cli as a dependency, so the tree is exactly the CLI and its transitive dependencies. npm cache is warm and the registry is only consulted for metadata, so install wall time is indicative, not a network benchmark.
| Metric | baseline v4.0.0-alpha.1 | head v4.0.0-alpha.1 | Delta |
|---|---|---|---|
Direct dependencies of @nuxt/cli |
23 | 23 | 0.0% |
| Packages in the installed tree (unique name@version) | 39 | 39 | 0.0% |
| Unique package names | 39 | 39 | 0.0% |
| Package directories on disk (cross-check) | 32 | 32 | 0.0% |
Installed node_modules on disk |
2.45 MB | 2.45 MB | +0.2% |
| Installed files | 434 | 435 | +0.2% |
| Install wall time (warm npm cache, median of 3) | 996 ms | 1.01 s | +1.9% |
| Published tarball (packed) | 239.6 kB | 240.9 kB | +0.5% |
| Published tarball (unpacked) | 775.2 kB | 779.8 kB | +0.6% |
| Files in tarball | 99 | 100 | +1.0% |
Interleaved runs on a shared runner: trust the deltas, not the absolute timings. The dev, restart and build suites run locally via pnpm bench:cli.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1592 +/- ##
=======================================
Coverage ? 83.46%
=======================================
Files ? 177
Lines ? 11371
Branches ? 3267
=======================================
Hits ? 9491
Misses ? 1584
Partials ? 296 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Editing
.envduringnuxt devprints.env changed. Restarting Nuxt in a new process..., but the new process keeps serving the old values.Cause
ForkPool.createForkpasses{ ...process.env }to the fork. By then the parent'sprocess.envalready contains whatever the previous.envset.setupDotenvin c12 only overwrites a variable when it isundefinedor when c12 set it itself, and it tracks which ones it set inglobalThis.__c12_dotenv_vars__. That record is per process, so inside the fork the stale values look like real shell variables. The fresh.envnever wins: a changed value is ignored, and a removed one stays.Fix
Before forking, drop the variables that c12 recorded as set by
.envfiles in this process (withoutDotenvVarsindev/pool.ts). The fork then loads.envfrom scratch. Variables that came from the shell are not in that record, so they are passed through unchanged. If the record is missing (another c12), the env is passed as before.Reproduction
The fixture's
nuxt.config.tshasruntimeConfig: { public: { benchMarker: '' } }, and the dev server runs withCI=1:after)third)mainbenchMarker:"before"❌benchMarker:"after"✅benchMarker:"third"✅Checks
eslintandtsc --noEmitpassvitest run packages/nuxt-cli/test/unitplus e2edev-restartanddev: 134 files, 1881 tests passed🤖 Generated with Claude Code