Returns invalid watch ID on failed addWatch
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:
- Create a Neutralinojs app and enable the native API.
- Call
Neutralino.filesystem.createWatcher("/path/does/not/exist"). - Observe that a watch ID is returned.
- Call
Neutralino.filesystem.removeWatcher(<returned_id>)and see it fail or behave inconsistently.
Expected behaviorcreateWatcher 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