You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
@workflow/next: infinite rebuild loop when Next.js uses a custom distDir (watcher ignore list misses it) #2809
The Next.js plugin's file watcher hardcodes an ignore list (/.next/, /dist/, /build/, /.cache/, …) in packages/next (builder-eager.js, ignoredPathFragments). If a project sets a custom distDir in next.config — e.g. distDir: ".next-dev" for dev — the watcher does NOT ignore it. Every Next compile then re-triggers the workflow builder, whose writes re-trigger Next, producing an infinite rebuild loop.
Versions
workflow 4.2.5, @workflow/next 4.0.6
next 14.2.35, macOS (darwin arm64), next dev (webpack)
Mechanism
The plugin (re)builds and writes generated files under app/.well-known/workflow/v1/ (including an unconditional writeFile of config.json, so mtimes bump even when content is unchanged).
Next.js watches app/, recompiles, and writes compiler output to the custom distDir (.next-dev/ in our case).
The plugin's watchpack instance ignores /.next/ but not .next-dev/, sees the output change, and rebuilds → back to 1.
Observed impact
~0.5–1.5 rebuild cycles/sec continuously while next dev runs; one 2.5 h session logged 14,080 "Discovering workflow directives / Created steps bundle" cycles.
Each cycle triggers Fast Refresh; with a dashboard tab open on a force-dynamic server-component page, its data reads re-ran continuously — we measured 620 Redis commands/min from a single idle browser tab, which exhausted an Upstash free-tier monthly quota (500k requests) in a few days of normal development.
Constant CPU churn from the compile loop even with no tab open.
Any project with the workflow Next plugin enabled; run next dev.
Watch the terminal: Discovering workflow directives → Created steps bundle → ✓ Compiled → … repeats forever with no source changes.
Renaming the dev distDir to .cache/next-dev (a fragment the hardcoded list happens to ignore) stops the loop immediately (0 rebuilds over 90 s, was ~50–100).
Suggested fixes
Read the resolved distDir from the Next config and add it to the watcher's ignore list, rather than relying on hardcoded names.
Independently: skip the write when generated file content is unchanged (compare before writeFile), which would break the cycle even for unknown watched paths.
@stefanlytzen-coder Should be fixed now and out in the next 5.x beta! when the backport merges it will be out in the next 4.x stable release as well so let us know if still getting issues!
Activity
NathanColosimo commentedon Jul 8, 2026
@stefanlytzen-coder Should be fixed now and out in the next 5.x beta! when the backport merges it will be out in the next 4.x stable release as well so let us know if still getting issues!