Skip to content

It hangs when ignore entry starts with / #99

@hi-ogawa

Description

@hi-ogawa

Vitest issue: vitest-dev/vitest#7598
reproduction: https://stackblitz.com/edit/github-koqytcnx?file=repro-tinyglobby.js

Vitest users reported an issue after switching to tinyglobby in Vitest 3.0.6. For Vitest use cases, this is mostly considered as a user side mis-configuration, so it's not critical, but it looks like something unintended going on, so I reduced the repro and report it here.

On stackblitz, it doesn't hang and glob returns empty, so the underlying issue might be same as #94.

Here is the code:

import { globSync } from 'tinyglobby';

console.time('tinyglobby');

const files = globSync(['demo.test.ts'], {
  ignore: ['/xxx/**'],
  expandDirectories: false,
  debug: true,
});

console.timeEnd('tinyglobby');

console.log('\n==== files ====');
console.log(files);

On my linux pc:

$ node repro-tinyglobby.js 
[tinyglobby 9:47:24] globbing with options: {
  ignore: [ '/xxx/**' ],
  expandDirectories: false,
  debug: true,
  patterns: [ 'demo.test.ts' ]
} cwd: /home/hiroshi/code/tmp/vitest-7598-tinyglobby
[tinyglobby 9:47:24] internal processing patterns: { match: [ 'demo.test.ts' ], ignore: [ '../../../../../xxx/**' ] }
[tinyglobby 9:47:24] internal properties: { root: '/', commonPath: null, depthOffset: -5 }
... hangs with 100% CPU usage ...

On stackblitz:

$ node repro-tinyglobby.js
[tinyglobby 9:50:13] globbing with options: {
  ignore: [ '/xxx/**' ],
  expandDirectories: false,
  debug: true,
  patterns: [ 'demo.test.ts' ]
} cwd: /home/projects/github-koqytcnx
[tinyglobby 9:50:13] internal processing patterns: { match: [ 'demo.test.ts' ], ignore: [ '../../../xxx/**' ] }
[tinyglobby 9:50:13] internal properties: { root: '/', commonPath: null, depthOffset: -3 }
[tinyglobby 9:50:13] skipped /bin/
[tinyglobby 9:50:13] skipped /dev/
[tinyglobby 9:50:13] skipped /etc/
[tinyglobby 9:50:13] skipped /home/
[tinyglobby 9:50:13] skipped /tmp/
[tinyglobby 9:50:13] skipped /usr/
tinyglobby: 14.45ms

==== files ====
[]

Also there's no issue with fast-glob:

$ node repro-fast-glob.js 
fast-glob: 2.942ms
[ 'demo.test.ts' ]

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions