fix(dev): let a restarted fork reload changed .env values - #1592
productdevbook wants to merge 1 commit into
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>
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 39 minutes. View limit detailsLimit details: You’ve used all 2 included reviews currently available. Review configuration: ⚙️ Run configuration
📒 Files selected for processing (1)
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 dcaf00c (v4.0.0-alpha.1) |
| Node | v24.21.0 |
| OS | Linux 6.17.0 (kernel 6.17.0-1022-azure) |
| CPU | INTEL(R) XEON(R) PLATINUM 8573C x 4 |
| Memory | 15.6 GB |
| Load average at start | 1.34, 0.37, 0.13 |
| Run started | 2026-10-03T17:10:45.375Z |
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 |
51 ms | 52 ms | +0.6% | 48 ms / 55 ms | 49 ms / 58 ms |
nuxt --version (first output byte) |
49 ms | 49 ms | +1.0% | 46 ms / 52 ms | 46 ms / 55 ms |
nuxt --help |
105 ms | 103 ms | -2.0% | 101 ms / 108 ms | 98 ms / 108 ms |
nuxt --help (first output byte) |
103 ms | 100 ms | -2.4% | 99 ms / 105 ms | 96 ms / 105 ms |
nuxt dev --help |
81 ms | 81 ms | +1.0% | 78 ms / 82 ms | 76 ms / 84 ms |
nuxt dev --help (first output byte) |
78 ms | 78 ms | +0.7% | 75 ms / 80 ms | 74 ms / 81 ms |
nuxt <unknown-command> (no-op) |
110 ms | 111 ms | +0.4% | 106 ms / 114 ms | 105 ms / 115 ms |
nuxt <unknown-command> (no-op) (first output byte) |
107 ms | 107 ms | +0.1% | 103 ms / 111 ms | 102 ms / 111 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 | 134 | 0.0% | 839.9 kB | 840.4 kB | +0.1% | 87 | 87 | 0.0% |
nuxt dev --help |
63 | 63 | 0.0% | 453.0 kB | 453.4 kB | +0.1% | 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.43 MB | 2.43 MB | +0.0% |
| Installed files | 434 | 434 | 0.0% |
| Install wall time (warm npm cache, median of 3) | 1.03 s | 1.03 s | -0.5% |
| Published tarball (packed) | 239.6 kB | 239.8 kB | +0.1% |
| Published tarball (unpacked) | 775.2 kB | 775.7 kB | +0.1% |
| Files in tarball | 99 | 99 | 0.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.39%
=======================================
Files ? 177
Lines ? 11311
Branches ? 3244
=======================================
Hits ? 9433
Misses ? 1582
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