fix: handle FIFO env sources (1Password Environments) across integrations#884
Open
theoephraim wants to merge 1 commit into
Open
fix: handle FIFO env sources (1Password Environments) across integrations#884theoephraim wants to merge 1 commit into
theoephraim wants to merge 1 commit into
Conversation
…ions Env sources served as FIFOs/named pipes broke dev-server watching: any read of the pipe makes the serving process rewrite it, firing new fs events. Detect non-regular files and never read, watch, or write them from reload machinery; log a one-time notice that live reload is disabled for them. - nextjs: fixes next dev hanging at startup on Linux (hash-read livelock) and repeated no-op reload logs; also preserves __VARLOCK_NEXT_* control vars across env resets - cloudflare: fixes varlock-wrangler dev endless no-op reload log loop on macOS; also ignores watch events with unchanged mtime (closes #845) - vite: skip FIFO sources in configFileDependencies with a notice - varlock core: write-back refuses non-regular source files with a clear error instead of blocking on the pipe
Contributor
|
The changes in this PR will be included in the next version bump.
|
@varlock/ci-env-info
varlock
@varlock/cloudflare-integration
@varlock/nextjs-integration
@varlock/vite-integration
commit: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Env sources served as FIFOs/named pipes (e.g. 1Password Environments mounting
.env) broke dev-server watching. Any read of the pipe makes the serving process rewrite it, which fires new fs events, which triggers another reload check that reads the pipe again. Depending on platform and integration this manifested as log spam, an endless reload loop, or a full hang.The fix, applied consistently everywhere the reload machinery touches env source paths: detect non-regular files (
statSync().isFile()) and never read, watch, or write them, logging a one-time notice that live reload is disabled for that file. Values from FIFO sources still load normally; a dev-server restart picks up changes (live reload of per-read-generated content is inherently impossible).Per package
next devhung forever at startup on Linux (content-hashreadFileSyncof the FIFO livelocks, no EOF) and loopedchange detected... skipping reloadlogs on macOS. FIFO sources are now excluded from content hashing, extra-file watchers, and reload-trigger-file selection (writing to a pipe blocks). Also preserves__VARLOCK_NEXT_*control vars across env resets and demotes FIFO watch-churn skip-logs to debug.varlock-wrangler devwith a FIFO.envprinted 70 no-op reload logs in 50s on macOS (self-sustaining from boot). FIFO sources are no longer watched. Also ignores watch events where mtime is unchanged, so other tools merely opening env files no longer cause no-op reload logs — closes varlock-wrangler logs repeated no-op env reloads on macOS #845.configFileDependencies(chokidar happened to ignore them silently; now it's explicit, with the notice). Covers astro/sveltekit/tanstack-start, which wrap this plugin.writeBackValue(local-encrypt) stat-checks before reading and returns a clearnon-regular-source-fileerror instead of potentially blocking on the pipe.Supersedes #883: the
disableWatchoption proposed there only tore down varlock's extrafs.watchFilewatchers, but the loop also runs through Next's own.envwatcher plus varlock's content-hash reads, and required users to discover a config flag. Auto-detection fixes the root cause with no config. (ThereplaceProcessEnvcontrol-var preservation from that PR is included here — thanks @mhornbacher.)Verification
Each integration was exercised end-to-end against a real FIFO
.env(loop-served, mimicking 1Password) on both macOS and Linux (docker), baseline vs fixed, plus regular-file regression runs confirming live reload still works. Unit tests added for the nextjs watcher/hash behavior and core write-back guard.