Skip to content

fix: handle FIFO env sources (1Password Environments) across integrations#884

Open
theoephraim wants to merge 1 commit into
mainfrom
fifo-env-sources
Open

fix: handle FIFO env sources (1Password Environments) across integrations#884
theoephraim wants to merge 1 commit into
mainfrom
fifo-env-sources

Conversation

@theoephraim

Copy link
Copy Markdown
Member

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

  • nextjs: next dev hung forever at startup on Linux (content-hash readFileSync of the FIFO livelocks, no EOF) and looped change detected... skipping reload logs 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.
  • cloudflare: varlock-wrangler dev with a FIFO .env printed 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.
  • vite: FIFO sources are skipped when registering configFileDependencies (chokidar happened to ignore them silently; now it's explicit, with the notice). Covers astro/sveltekit/tanstack-start, which wrap this plugin.
  • varlock core: writeBackValue (local-encrypt) stat-checks before reading and returns a clear non-regular-source-file error instead of potentially blocking on the pipe.

Supersedes #883: the disableWatch option proposed there only tore down varlock's extra fs.watchFile watchers, but the loop also runs through Next's own .env watcher plus varlock's content-hash reads, and required users to discover a config flag. Auto-detection fixes the root cause with no config. (The replaceProcessEnv control-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.

…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
@github-actions

Copy link
Copy Markdown
Contributor

bumpy-frog

The changes in this PR will be included in the next version bump.

patch Patch releases

  • @varlock/astro-integration 1.1.1 → 1.1.2 (cascade)
  • @varlock/cloudflare-integration 1.2.1 → 1.2.2
  • @varlock/nextjs-integration 1.1.4 → 1.1.5
  • @varlock/vite-integration 1.2.1 → 1.2.2
  • varlock 1.10.0 → 1.10.1

Bump files in this PR

Click here if you want to add another bump file to this PR


This comment is maintained by bumpy.

@pkg-pr-new

pkg-pr-new Bot commented Jul 15, 2026

Copy link
Copy Markdown

Open in StackBlitz

@varlock/ci-env-info

npm i https://pkg.pr.new/@varlock/ci-env-info@884

varlock

npm i https://pkg.pr.new/varlock@884

@varlock/cloudflare-integration

npm i https://pkg.pr.new/@varlock/cloudflare-integration@884

@varlock/nextjs-integration

npm i https://pkg.pr.new/@varlock/nextjs-integration@884

@varlock/vite-integration

npm i https://pkg.pr.new/@varlock/vite-integration@884

commit: 0d71993

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

varlock-wrangler logs repeated no-op env reloads on macOS

1 participant