fix: handle non-regular files in dev watcher to prevent crashes#14854
fix: handle non-regular files in dev watcher to prevent crashes#14854RomanBaiocco wants to merge 4 commits intoremix-run:devfrom
Conversation
|
Hi @RomanBaiocco, Welcome, and thank you for contributing to React Router! Before we consider your pull request, we ask that you sign our Contributor License Agreement (CLA). We require this only once. You may review the CLA and sign it by adding your name to contributors.yml. Once the CLA is signed, the If you have already signed the CLA and received this response in error, or if you have any questions, please contact us at hello@remix.run. Thanks! - The Remix team |
🦋 Changeset detectedLatest commit: 8231128 The changes in this PR will be included in the next version bump. This PR includes changesets to release 11 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
001ad02 to
0d7e61f
Compare
|
Thank you for signing the Contributor License Agreement. Let's get this merged! 🥳 |
abfc22e to
b5a8e19
Compare
ce9b080 to
990409d
Compare
The dev file watcher crashes when Unix socket files (e.g. from overmind or pm2) exist in the project root. chokidar v4 calls fs.watch() on these files, which fails on macOS with errno -102 (UNKNOWN). - Extract watcher ignore logic into an exported `isIgnoredByWatcher` function for testability - Run cheap path-based checks before the fs.statSync call to avoid unnecessary syscalls on already-ignored paths - Filter non-regular files (sockets, pipes, etc.) via fs.statSync - Add an error handler on the watcher so unexpected errors log a warning instead of crashing the process Fixes: https://github.com/RomanBaiocco/react-router-sock-repro Related: paulmillr/chokidar#1391
9fb8a25 to
6091dc8
Compare
Summary
Fixes #14855
react-router devcrashes when Unix socket files (.sock) exist in the project root directory. This commonly happens when using process managers like overmind or pm2, which create socket files in the working directory.The crash occurs because
@react-router/dev's chokidar v4 watcher attempts to callfs.watch()on socket files, which fails on macOS withUNKNOWN: unknown error, watch(errno -102).Changes
ignoredcallback into an exportedisIgnoredByWatcherfunction for testabilityfs.statSyncto avoid unnecessary syscalls on already-ignored pathsfs.statSyncso chokidar never tries to watch themerrorevent handler on the watcher so unexpected errors log a warning viapicocolorsinstead of crashing the processReproduction
Full repro repo with steps: https://github.com/RomanBaiocco/react-router-sock-repro
Quick repro:
Related
/var/runon macOS Sequoia with v4 paulmillr/chokidar#1391