Skip to content

bug: watch rebuild hangs due to Rollup fileOperationQueue deadlock (bundled Rollup 4.34.9) #6602

@adrianschmidt

Description

@adrianschmidt

Prerequisites

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):

  1. On rebuild, Rollup passes all cached modules (3687 in our case) through addModuleSource, which uses a fileOperationQueue limited to maxParallelFileOps (default: 20)
  2. The @rollup/plugin-commonjs load hook calls this.load() internally
  3. With enough concurrent modules, the outer load calls saturate the 20-slot queue, and the nested this.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

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

  1. Use a Stencil project with a large number of components (100+ components, 3000+ modules in the Rollup graph)
  2. Run stencil build --dev --watch --serve
  3. Wait for initial build to complete
  4. Modify any component file
  5. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bug: ValidatedThis PR or Issue is verified to be a bug within Stencil

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions