Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Errors within add bubble as unhandled rejections #1378

Open
bradymadden97 opened this issue Oct 21, 2024 · 1 comment
Open

Errors within add bubble as unhandled rejections #1378

bradymadden97 opened this issue Oct 21, 2024 · 1 comment

Comments

@bradymadden97
Copy link

bradymadden97 commented Oct 21, 2024

Describe the bug

A clear and concise description of what the bug is.

Versions (please complete the following information):

  • Chokidar version [e.g. 3.2.1 or commit hash] 3.6.0
  • Node version [e.g. 12.11.0, ensure you are using the latest node.js] 20.9.0
  • OS version: [e.g. Ubuntu 19.04 or MacOS 10.15 or Windows 10]

To Reproduce:

We have a number of these stack traces where an error occurs within the async function on this line:

Error: ENOSPC: System limit for number of file watchers reached, watch '/home/runner/Foodsource5/add_test_data.py'
  File "node:internal/fs/watchers", line 247, col 19, in FSWatcher.<computed>
  File "node:fs", line 2392, col 36, in Object.watch
  File "../../../node_modules/.pnpm/chokidar@3.6.0/node_modules/chokidar/lib/nodefs-handler.js", line 119, col 15, in createFsWatchInstance
    return fs.watch(path, options, handleEvent);
  File "../../../node_modules/.pnpm/chokidar@3.6.0/node_modules/chokidar/lib/nodefs-handler.js", line 166, col 15, in setFsWatchListener
    watcher = createFsWatchInstance(
  File "../../../node_modules/.pnpm/chokidar@3.6.0/node_modules/chokidar/lib/nodefs-handler.js", line 331, col 14, in NodeFsHandler._watchWithNodeFs
    closer = setFsWatchListener(path, absolutePath, options, {
  File "../../../node_modules/.pnpm/chokidar@3.6.0/node_modules/chokidar/lib/nodefs-handler.js", line 395, col 23, in NodeFsHandler._handleFile
    const closer = this._watchWithNodeFs(file, listener);
  File "../../../node_modules/.pnpm/chokidar@3.6.0/node_modules/chokidar/lib/nodefs-handler.js", line 637, col 21, in NodeFsHandler._addToNodeFs
    closer = this._handleFile(wh.watchPath, stats, initialAdd);
  File "../../../node_modules/.pnpm/chokidar@3.6.0/node_modules/chokidar/index.js", line 451, col 21, in <anonymous>
    const res = await this._nodeFsHandler._addToNodeFs(path, !_internal, 0, 0, _origAdd);
  File "index 0", in Promise.all

It bubbles, but since add is sync, and there is no .catch on this line, its thrown to the global unhandled rejection handler. Would it be possible to update the API to allow callsites to handle this error more locally? Either make add async, add an error callback parameter, etc.?

I checked v4.0 and it appears the same code is still in place.

Thank you!

Expected behavior
A clear and concise description of what you expect to happen.

Additional context
Add any other context about the problem here.
Optionally nice to know what project you are working on.

@43081j
Copy link
Collaborator

43081j commented Oct 22, 2024

It would be a new major to make it async I think (breaking change). Maybe we could emit errors through the existing error handling?

Though you wouldn't have a direct connection between the call site and the error thrown, since it would be a separate event fired

Otherwise we would need to change add to take an optional callback or something

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants