mirror of
https://github.com/davidkaya/aryx.git
synced 2026-07-24 05:28:46 +02:00
fix: handle async FSWatcher errors in project customization watcher
On Linux, fs.watch() on a non-existent directory emits an asynchronous 'error' event instead of throwing synchronously. Without an error handler, this crashes the process. Tests that create AryxAppService with fake project paths (e.g. C:\workspace\project-one) trigger this on Linux CI because those paths don't exist. Attach an 'error' event handler to the FSWatcher that logs a warning and closes the watcher gracefully. This fixes the Linux CI 'bun test' failure and also prevents production crashes if a watched directory is deleted at runtime. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -169,7 +169,14 @@ async function collectExistingDirectories(rootPath: string): Promise<string[]> {
|
||||
}
|
||||
|
||||
function createProjectWatchHandle(directoryPath: string, onChange: () => void): ProjectWatchHandle {
|
||||
return watch(directoryPath, { persistent: false }, () => {
|
||||
const watcher = watch(directoryPath, { persistent: false }, () => {
|
||||
onChange();
|
||||
});
|
||||
|
||||
watcher.on('error', (error) => {
|
||||
console.warn(`[aryx customization] Watcher error for ${directoryPath}:`, error);
|
||||
watcher.close();
|
||||
});
|
||||
|
||||
return watcher;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user