Skip to content

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

@SuperchupuDev

Description

@SuperchupuDev

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions