Repository navigation
Only re-resolve env on Vite/Nuxt dev restarts when env files changed - #1270
Conversation
The close hook also fires on final shutdown (Ctrl+C), so every quit re-resolved the env, re-running plugin resolvers and re-triggering auth prompts such as 1Password. It now refreshes only when the env files differ from what the instance loaded: loaded sources plus any .env* file next to them, so a newly created .env still refreshes on the CLI's direct reload path. Fixes #1249
|
The changes in this PR will be included in the next version bump.
|
varlock
@varlock/astro-integration
@varlock/cloudflare-integration
@varlock/nuxt-integration
@varlock/vite-integration
@varlock/native-helper-darwin
@varlock/native-helper-linux-arm64
@varlock/native-helper-linux-x64
@varlock/native-helper-win32-x64
@varlock/1password-plugin
@varlock/bitwarden-plugin
@varlock/keepass-plugin
@varlock/pass-plugin
@varlock/proton-pass-plugin
commit: |
There was a problem hiding this comment.
Important
Config-only reloads can now read one env snapshot in nuxt.config.ts and resolve another during Vite setup. The unchanged-env decision needs to carry through to the composed Vite plugin.
Reviewed changes: Reviewed the file-fingerprint guard, Nuxt lifecycle hooks, regression tests, and documentation, including their interaction with Vite's reload state.
- Shutdown guard: Captures env-file metadata during dev setup and skips the close-hook refresh when nothing changed, while retaining restart deduplication.
- Regression coverage: Adds creation, modification, and unchanged-shutdown tests; all 17 Nuxt tests and 31 Vite tests passed after generating the parser prerequisite.
- Documented behavior: Updates the dev-server guidance and release note to describe reuse on shutdown and unchanged-env reloads.
gpt-6.1-sol | 𝕏
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
varlock-website | 6bf4bea | Commit Preview URL Branch Preview URL |
Nov 03 2026, 08:46 PM |
Replace the consumed-load flag with a stat fingerprint of the env files a load could read. Dev restarts and the new ensureVarlockEnvFresh() only re-resolve when an env file changed or appeared, or the last load failed, so a config-only reload keeps the snapshot its config was evaluated against. The Nuxt module calls ensureVarlockEnvFresh() from both reload hooks instead of fingerprinting itself, which also replaces its restart/close dedupe flag. Startup adopts a graph varlock/auto-load already resolved from the same directory, and a telemetry name change no longer reloads. A Nuxt dev server now resolves env once at startup instead of four times.
checkEnvSourceDrift (varlock/env-source-fingerprint) re-hashes each recorded file source against the contentHash taken when it was parsed, and checks the new absentSourcePaths list: auto-load candidates and allowMissing imports a load looked for and did not find. Creating one of those now counts as drift, which closes the documented gap in injected-env reuse. The vite integration uses it for dev-restart freshness instead of its own mtime fingerprint, so an edit made during a slow load is still caught and an unrelated .env.example no longer triggers a reload.
📦 Bundle size
dist/ only; native binaries are versioned separately and not counted here. |
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes: Reviewed the changes since f1b1b1fd, including shared source-drift detection, Vite snapshot reuse, and Nuxt lifecycle coordination.
- Centralized drift detection: Added recorded absent-source paths and a shared content-hash check, also used by injected-env reuse to detect newly created env files.
- Unified dev freshness: Replaced Vite's consumed-load flag with conditional refresh and routed both Nuxt reload hooks through it, preserving the same snapshot across unchanged config reloads.
- Reduced startup resolution: Adopted same-directory auto-loaded graphs and stopped reloading solely for integration telemetry changes.
- Expanded regression coverage: Added freshness and startup tests plus documentation; 41 Vite, 14 Nuxt, and 59 focused core tests passed after building test prerequisites. No end-to-end Nuxt/1Password reproduction was run.
gpt-6.1-sol | 𝕏



Fixes #1249.
Nuxt's dev
closehook fires on both reloads and final shutdown (Ctrl+C), and nothing tells them apart. The module forced an env refresh in it, so every quit re-ran resolvers and could re-trigger auth prompts (e.g. 1Password). Dev restarts also loaded env several times each.The fix makes "is the loaded env still fresh?" a single check, owned by core:
absentSourcePaths(auto-load candidates like.env.localandallowMissingimports that were not found). NewcheckEnvSourceDrift(graph), exported asvarlock/env-source-fingerprint, re-hashes each source against its recordedcontentHashand checks whether any absent path now exists. It reads and hashes files only, no parsing or resolution. Injected-env reuse uses it too, so creating.env.localundervarlock runis no longer missed.ensureVarlockEnvFresh(rootDir)reloads only when env files drifted. Dev config resolution uses it instead of theloadIsUnconsumedflag. At startup it adopts the graphvarlock/auto-loadalready resolved (same dir only), and a telemetry option change no longer triggers a reload.refreshVarlockEnvstays a forced reload.restartandclosecallensureVarlockEnvFresh, so a quit or anuxt.config-only reload resolves nothing.Checked in a Nuxt 4.6.3 /
@nuxt/cli4.0.1 app with anexec()resolver that logs each run:varlock run).env.schema.envA
nuxt.configedit, with or without a new.env.example, now resolves nothing. Served values and config-time reads are correct after every change.Behavior change: a dev restart with no env file change (including the
rshortcut) no longer re-fetches remote values (vaults,exec(), 1Password Environments FIFOs). Stop and start the dev server to pick those up. Documented in the vite and nuxt guides.