Skip to content

fix(pv-scripts): pin fork-ts-checker to 9.0.3 (fix macOS EMFILE)#250

Merged
friewerts merged 1 commit into
developfrom
fix/emfile-fork-ts-checker-chokidar
Jul 1, 2026
Merged

fix(pv-scripts): pin fork-ts-checker to 9.0.3 (fix macOS EMFILE)#250
friewerts merged 1 commit into
developfrom
fix/emfile-fork-ts-checker-chokidar

Conversation

@friewerts

Copy link
Copy Markdown
Member

Problem

On macOS pv-scripts dev crashes with EMFILE: too many open files, watch as soon as a page compiling several (lazy) bundles is opened, when the TS type-check is enabled. Regression introduced in pv-scripts 6 (fine in 5.0.1).

Error: EMFILE: too many open files, watch
    at FSWatcher._handle.onchange (node:internal/fs/watchers)
    at FSWatcher._handleError (node_modules/chokidar/index.js:539:18)
    at NodeFsHandler._boundHandleError (node_modules/chokidar/handler.js:300:49)

Root cause

  • fork-ts-checker-webpack-plugin@9.1.0 bumped its chokidar dependency 3 → 4.
  • chokidar@4 dropped fsevents. On macOS it therefore falls back to native fs.watch, which opens one file descriptor per watched directory instead of a single fsevents stream.
  • fork-ts-checker watches every tsconfig wildcard directory with its own chokidar.watch(). A tsconfig.json without include makes TypeScript watch the whole project root incl. node_modules, so the FD count explodes and exhausts the per-process limit.

The regression is specific to 9.1.0 — versions 9.0.0–9.0.3 use chokidar@^3.5.3 (with fsevents).

Fix

Pin fork-ts-checker-webpack-plugin to 9.0.3 (last release on the chokidar-3 line). The entire diff 9.0.3 → 9.1.0 is: the chokidar major bump, a version string, and one cosmetic log message — the watch code is byte-identical. So this is a no-risk, transparent fix shipped to all consumers (no consumer-side overrides required).

Also documents enableTypeCheck (was missing from the config table) and adds a Troubleshooting section (tsconfig include, overrides, enableTypeCheck: false).

Verification (macOS, real consumer)

Test before (9.1.0 / chokidar 4) after (9.0.3 / chokidar 3)
pv-scripts dev + open the crashing styleguide URL EMFILE crash @ ~12s stable 150s, 0 EMFILE
open FDs of the dev process crash ~54–60 (fsevents)
isolated watch of the real consumer tree EMFILE @ 9,879 FDs 22 FDs
type-check catches TS2322, passes clean code

🤖 Generated with Claude Code

fork-ts-checker-webpack-plugin@9.1.0 bumped chokidar 3 -> 4, and
chokidar 4 dropped fsevents. On macOS the TS type-check watcher then
falls back to native fs.watch (one descriptor per directory) instead of
a single fsevents stream, so watching a large tree (e.g. a tsconfig
without `include`, which watches the project root incl. node_modules)
crashes `pv-scripts dev` with `EMFILE: too many open files, watch`.

Pin to 9.0.3, the last release on chokidar 3 (fsevents). The only
difference between 9.0.3 and 9.1.0 is the chokidar major bump plus a
cosmetic log string; the watch code is byte-identical, so this is a
no-risk, transparent fix for all consumers.

Verified on macOS against a real consumer: dev server stable, open FDs
drop from ~9.9k (EMFILE crash) to ~22 via fsevents, type-check intact.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@friewerts friewerts merged commit a601083 into develop Jul 1, 2026
2 checks passed
@friewerts friewerts deleted the fix/emfile-fork-ts-checker-chokidar branch July 1, 2026 07:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant