Returns invalid watch ID on failed addWatch

Author: AAdIprogCreated Mar 5, 2026Updated Sep 12, 2026
Labelsbug

Neutralino.filesystem.createWatcher does not handle failures from the underlying watcher (e.g., non-existent or inaccessible paths). It still registers and returns an invalid watch ID, which can leave the watcher in an inconsistent state.

To Reproduce
Steps to reproduce the behavior:

  1. Create a Neutralinojs app and enable the native API.
  2. Call Neutralino.filesystem.createWatcher("/path/does/not/exist").
  3. Observe that a watch ID is returned.
  4. Call Neutralino.filesystem.removeWatcher(<returned_id>) and see it fail or behave inconsistently.

Expected behavior
createWatcher should return an error (or a failure result) when it cannot register the path, and it should not store an invalid watcher internally.

Screenshots/Screen recordings
Not applicable.

Specifications

  • OS: macOS 14.x (Apple Silicon)
  • Neutralinojs version: [fill from neu version]
  • Neutralinojs client library version: [fill from neu version]
  • Neutralinojs CLI version: [fill from neu version]

Additional context
This happens when the path does not exist or is not watchable. The returned ID can be invalid (e.g., -1), but it still gets stored and returned, which can lead to leaks and future API failures.

Source: neutralinojs/neutralinojs