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

Regression: maxDepth silent crash on windows if set to less than 0 #127

Closed
SuperchupuDev opened this issue Oct 16, 2024 · 10 comments
Closed

Comments

@SuperchupuDev
Copy link
Contributor

SuperchupuDev commented Oct 16, 2024

I have no idea what causes this, but 6.4.1 broke tinyglobby tests on windows by throwing that in some tests. I have no idea if users are affected. Looking this issue up shows it might be related to node's test runner though

Seems to be thrown by a test that sets the maxDepth option, once it gets thrown node:test propagates it to all remaining tests

https://github.com/SuperchupuDev/tinyglobby/actions/runs/11371715863/job/31634407668?pr=60

EDIT: also happens outside node:test, instead of throwing an error it..doesn't run? definitely can affect users

repro code:

import path from 'node:path';
import { convertPathToPattern, glob } from 'tinyglobby';

import { createFixture } from 'fs-fixture';

const fixture = await createFixture({
  a: {
    'a.txt': 'a',
    'b.txt': 'b'
  },
  b: {
    'a.txt': 'a',
    'b.txt': 'b'
  },
  '.a/a/a.txt': 'a',
  '.deep/a/a/a.txt': 'a',
  '.symlink': {
    file: ({ symlink }) => symlink('../a/a.txt'),
    dir: ({ symlink }) => symlink('../a')
  }
});

const cwd = fixture.path;

console.log('a', cwd);

const a = await glob({ patterns: ['.deep/a/a/*.txt'], deep: 2, cwd });

console.log('hi', a); // this doesn't ever get logged for some reason

await fixture.rm();
@SuperchupuDev SuperchupuDev changed the title Error: Promise resolution is still pending but the event loop has already resolved Regression maxFiles can make node silenty crash on windows - Promise resolution is still pending but the event loop has already resolved Oct 16, 2024
@SuperchupuDev SuperchupuDev changed the title Regression maxFiles can make node silenty crash on windows - Promise resolution is still pending but the event loop has already resolved Regression: maxDepth can make node silenty crash on windows - Promise resolution is still pending but the event loop has already resolved Oct 16, 2024
@SuperchupuDev
Copy link
Contributor Author

SuperchupuDev commented Oct 16, 2024

as a complete guess when early debugging it might be related to queues and/or this:
image

@thecodrr
Copy link
Owner

Can't reproduce it.

@SuperchupuDev
Copy link
Contributor Author

SuperchupuDev commented Oct 16, 2024

are you on windows? anyways, reverting the queue refactor showcased in the screenshot seems to fix it, should i send a pr?

@thecodrr
Copy link
Owner

reverting the queue change

That was unnecessary because as you can see, it enqueues and then immediately dequeues. Instead of that now it just returns which should be fine since there was no enqueuing.

@thecodrr
Copy link
Owner

I am on Windows btw.

@SuperchupuDev
Copy link
Contributor Author

interesting, i'm going to try to add a repro as a failing test and will pr that for now then, it's weird because i can consistently reproduce in both my machine and tinyglobby's windows ci

@thecodrr
Copy link
Owner

Ran this:

const assert = require("node:assert");
const { fdir } = require("./dist/index");
const { test } = require("node:test");

test("test", async () => {
  await new fdir()
    .withMaxDepth(1)
    .withErrors()
    .crawl("node_modules")
    .withPromise();
});

And worked fine.

@SuperchupuDev
Copy link
Contributor Author

SuperchupuDev commented Oct 16, 2024

i see that tinyglobby ends up passing maxDepth as -1 in the example i sent, so it looks like it maybe happens when maxDepth is less than 0

@thecodrr
Copy link
Owner

Oh yes. Now I can repro it. Let me fix it.

@SuperchupuDev SuperchupuDev changed the title Regression: maxDepth can make node silenty crash on windows - Promise resolution is still pending but the event loop has already resolved Regression: maxDepth silent crash on windows if set to less than 0 Oct 16, 2024
@SuperchupuDev
Copy link
Contributor Author

SuperchupuDev commented Oct 16, 2024

can confirm the fix works by manually changing fdir in node_modules in 6.4.2. thanks for the extremely fast fix ❤️

btw, just a small patchnotes nit: you mention it happened when it's < 1 when in reality it happens when it's < 0

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