-
-
Notifications
You must be signed in to change notification settings - Fork 832
Description
Prerequisites
- I have read the Contributing Guidelines.
- I agree to follow the Code of Conduct.
- I have searched for existing issues that already report this problem, without success.
Stencil Version
4.43.0
Current Behavior
When running stencil build --dev --watch --serve, the initial build completes normally. On any subsequent file change, the rebuild hangs indefinitely at:
generate lazy + source maps started ...
Root Cause
Stencil 4.43.0 bundles Rollup 4.34.9, which contains a known deadlock bug (rollup/rollup#5848):
- On rebuild, Rollup passes all cached modules (3687 in our case) through
addModuleSource, which uses afileOperationQueuelimited tomaxParallelFileOps(default: 20) - The
@rollup/plugin-commonjsloadhook callsthis.load()internally - With enough concurrent modules, the outer
loadcalls saturate the 20-slot queue, and the nestedthis.load()calls queue behind them — creating a deadlock where no task can complete
This was fixed in Rollup 4.44.0 (rollup/rollup#5986) by setting the default maxParallelFileOps to Infinity.
Related Issues
- #6253 — same symptom, attributed to
maxParallelFileOpsbut the fix (PR feat(compiler): support maxParallelFileOps in RollupInputOptions #6255) only exposed the config option without changing the default - rollup/rollup#5848 — upstream bug report and fix
Suggested Fix
Update the bundled Rollup from 4.34.9 to ≥4.44.0.
As a temporary workaround, disabling the Rollup cache (setting cache: false in the rollup input options within bundleOutput) also resolves the issue, at the cost of slightly slower rebuilds (~7s full re-bundle vs near-instant from cache).
Expected Behavior
Watch mode rebuilds should complete without hanging.
Steps to Reproduce
- Use a Stencil project with a large number of components (100+ components, 3000+ modules in the Rollup graph)
- Run
stencil build --dev --watch --serve - Wait for initial build to complete
- Modify any component file
- Rebuild hangs at "generate lazy + source maps started"
System Info
macOS (Apple Silicon)
Stencil: 4.43.0 (bundles Rollup 4.34.9)
Node: 22.x
Debug Data
Instrumentation of Stencil's compiler confirms the hang:
[invalidateRollupCaches] changedFiles=1 invalidated=0 totalModules=3687
[bundleOutput] id=lazy cacheModules=3687 maxParallelFileOps=undefined
rollup() is called with 3687 cached modules and maxParallelFileOps defaulting to 20, and never returns.