You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
🤖 Fix double-close error by using 'using' pattern for directory handles
Replace try/finally with 'using' declaration for automatic resource cleanup.
This prevents ERR_DIR_CLOSED errors when the async iterator auto-closes
the directory handle and then finally block tries to close it again.
Key changes:
- Wrap Dir in AsyncDisposable object with Symbol.asyncDispose
- Use Promise.resolve() to handle Bun's synchronous close() behavior
- Properly catch errors if handle is already closed
- Tests verify correct cleanup in all scenarios (early break, full iteration)
The 'using' pattern ensures cleanup happens at scope exit, even with
early returns or exceptions, while gracefully handling double-close.
0 commit comments