fix(watcher): unref lingering FSWatcher handles after stopping the node watcher
This commit is contained in:
@@ -3,6 +3,6 @@
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@push.rocks/smartwatch',
|
||||
version: '6.3.0',
|
||||
version: '6.3.1',
|
||||
description: 'A cross-runtime file watcher with glob pattern support for Node.js, Deno, and Bun.'
|
||||
}
|
||||
|
||||
@@ -90,6 +90,14 @@ export class NodeWatcher implements IWatcher {
|
||||
this.watcher = null;
|
||||
}
|
||||
|
||||
// Unref any lingering FSWatcher handles from chokidar so they don't prevent process exit.
|
||||
// Chokidar v5's close() resolves before all fs.watch() handles are fully released.
|
||||
for (const handle of (process as any)._getActiveHandles()) {
|
||||
if (handle?.constructor?.name === 'FSWatcher' && typeof handle.unref === 'function') {
|
||||
handle.unref();
|
||||
}
|
||||
}
|
||||
|
||||
this._isWatching = false;
|
||||
console.log('[smartwatch] Watcher stopped');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user