Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

opendirSync successfully returns for a non-existent directory #17581

Open
dunhamsteve opened this issue Feb 23, 2025 · 1 comment · May be fixed by #17846
Open

opendirSync successfully returns for a non-existent directory #17581

dunhamsteve opened this issue Feb 23, 2025 · 1 comment · May be fixed by #17846
Labels
bug Something isn't working confirmed bug We can reproduce this issue node:fs

Comments

@dunhamsteve
Copy link

What version of Bun is running?

1.2.3+8c4d3ff80

What platform is your computer?

Darwin 24.3.0 arm64 arm

What steps can reproduce the bug?

Run the following file with bun (I'm assuming the directory xxxx does not exist):

console.log(require('fs').opendirSync('xxxx'))

What is the expected behavior?

Nodejs throws an error:

Error: ENOENT: no such file or directory, opendir

What do you see instead?

bun succeeds and returns a directory object:

Dir {
  readSync: [Function: readSync],
  read: [Function: read],
  close: [Function: close],
  closeSync: [Function: closeSync],
  path: [Getter],
  [Symbol(Symbol.asyncIterator)]: [AsyncGeneratorFunction],
}

Additional information

No response

@evanrittenhouse
Copy link

evanrittenhouse commented Feb 23, 2025

I'll pick this up. It looks like this is because node actually attempts to call the opendir syscall, whereas Bun just creates an object in JS-land.

@RiskyMH RiskyMH added node:fs confirmed bug We can reproduce this issue and removed needs triage labels Feb 24, 2025
evanrittenhouse added a commit to evanrittenhouse/bun that referenced this issue Mar 2, 2025
@evanrittenhouse evanrittenhouse linked a pull request Mar 2, 2025 that will close this issue
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working confirmed bug We can reproduce this issue node:fs
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants