What version of Bun is running?
1.4.0-canary.1+5ac120ca3
What platform is your computer?
Linux 6.12.86+deb13-amd64 x86_64 x86_64
What steps can reproduce the bug?
Hi,
I would like to report a behavior in Bun that can be reproduced using the below snippet:
import { promises as fs } from "node:fs";
const dir = await fs.opendir(".");
// create async iterator from the Dir handle
const iter = dir[Symbol.asyncIterator]();
// start reading one entry
await iter.next();
// close the directory while iterator is still “live”
await dir.close();
// now try to continue iteration
await iter.next();
What is the expected behavior?
root@KContainer:~/16622# node a.mjs
node:internal/fs/dir:254
process.nextTick(callback, new ERR_DIR_CLOSED());
^
Error [ERR_DIR_CLOSED]: Directory handle was closed
at Dir.close (node:internal/fs/dir:254:34)
at node:internal/util:500:21
at new Promise (<anonymous>)
at Dir.close (node:internal/util:486:12)
at Dir.entries (node:internal/fs/dir:304:35)
at async file:///home/c01kele/16622/a.mjs:15:1 {
code: 'ERR_DIR_CLOSED'
}
Node.js v24.13.1
What do you see instead?
No error is thrown; iteration continues or resolves without enforcing the closed state.
Additional information
No response
What version of Bun is running?
1.4.0-canary.1+5ac120ca3
What platform is your computer?
Linux 6.12.86+deb13-amd64 x86_64 x86_64
What steps can reproduce the bug?
Hi,
I would like to report a behavior in Bun that can be reproduced using the below snippet:
What is the expected behavior?
What do you see instead?
No error is thrown; iteration continues or resolves without enforcing the closed state.
Additional information
No response