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

withSymlinks({ resolvePaths: false }) hang when crawling / #135

Open
SuperchupuDev opened this issue Mar 7, 2025 · 1 comment
Open

withSymlinks({ resolvePaths: false }) hang when crawling / #135

SuperchupuDev opened this issue Mar 7, 2025 · 1 comment

Comments

@SuperchupuDev
Copy link
Contributor

SuperchupuDev commented Mar 7, 2025

works when resolving paths. repro code (only tested on linux):

import { fdir } from 'fdir';

const files = await new fdir()
  .exclude((_, f) => {
    // doing this to avoid crawling anything recursively
    console.log('ignoring', f);
    return true;
  })
  .withSymlinks({ resolvePaths: false })
  .crawl('/')
  .withPromise();

console.log(files);

it looks like isRecursive from resolve-symlinks.ts gets called with the following arguments and enters an infinite loop:

'/lib', '/usr/lib', {
  root: '',
  paths: [],
  groups: [],
  counts: Counter { _files: 0, _directories: 1 },
  options: {
    maxDepth: Infinity,
    suppressErrors: true,
    pathSeparator: '/',
    filters: [],
    exclude: [Function (anonymous)],
    resolveSymlinks: true,
    useRealPaths: false,
    resolvePaths: true,
    includeBasePath: true
  },
  queue: Queue { onQueueEmpty: [Function (anonymous)], count: 4 },
  symlinks: Map(0) {},
  visited: [ '/' ]
}

the while loop of the function seems to always run with the variables parent = "/", state.root = "", depth = 1. state.root doesn't look like it's properly computed?

@pralkarz
Copy link

pralkarz commented Mar 7, 2025

The incorrect state.root seems to stem from the change introduced in a492652. Changing it to this.root === "/" ? this.root : this.root.slice(0, -1) fixes the issue, but I don't know what the implications could be. 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants