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

It hangs when ignore entry starts with / #99

Open
hi-ogawa opened this issue Mar 3, 2025 · 1 comment
Open

It hangs when ignore entry starts with / #99

hi-ogawa opened this issue Mar 3, 2025 · 1 comment

Comments

@hi-ogawa
Copy link

hi-ogawa commented Mar 3, 2025

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' ]
@SuperchupuDev
Copy link
Owner

it sounds like a different issue than #94 (root not set to a malformed path here), will investigate

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