oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
74.53k stars 2.79k forks source link

node:fs/promises - opendir does not respect recursive option. #13717

Open justinweinberg opened 3 months ago

justinweinberg commented 3 months ago

What version of Bun is running?

1.1.26+0a37423ba

What platform is your computer?

Darwin 23.6.0 arm64 arm

What steps can reproduce the bug?

The following code in bun does not recurse subdirectories. It does in Node. Paste into an index.ts.

import { opendir } from 'node:fs/promises';

async function* list(path: string, deep: boolean) {
  const entries = await opendir(path, {
    recursive: deep,
  });

  for await (const item of entries) {
    yield item;
  }
}

async function go() {
  let count = 0;
  for await (let i of list("./", true)) {
    count += 1;
  }
  return count;
}

What is the expected behavior?

node --experimental-strip-types index.ts
3

bun index.ts
2

What do you see instead?

NodeJS returns the recursive result, in my case 3. Bun does not, in my case 2.

Additional information

No response

sylv commented 5 days ago

This not producing an obvious error makes it more problematic imo, it would be nice to have the option being present cause an error/warning until its implemented