fix(skill): cancel opening watchers on dispose

This commit is contained in:
Tianyi Cui
2026-07-29 21:17:04 +08:00
parent e9233123eb
commit 48cf50fc55
2 changed files with 17 additions and 6 deletions

View File

@@ -262,11 +262,10 @@ describe('skill-local watcher failures', () => {
await vi.waitFor(() => { expect(watcherHarness.watchers).toHaveLength(1) })
const first = watcherHarness.watchers[0]
if (first === undefined) throw new Error('expected an opening root watcher')
first.emitter.emit('unlinkDir', root)
const disposal = provider.dispose()
first.emitter.emit('ready')
await Promise.all([discovery, disposal])
await expect(discovery).rejects.toThrow('skill-local watcher disposed')
await disposal
disposeProvider()
await settle()
expect(first.closeCalls).toBeGreaterThan(0)
@@ -295,8 +294,8 @@ describe('skill-local watcher failures', () => {
await vi.waitFor(() => { expect(watcherHarness.watchers).toHaveLength(1) })
const first = watcherHarness.watchers[0]
if (first === undefined) throw new Error('expected an opening root watcher')
const disposal = provider.dispose()
first.emitter.emit('error', new Error('opening failed during disposal'))
const disposal = provider.dispose()
await expect(discovery).rejects.toThrow('opening failed during disposal')
await disposal