-
-
Notifications
You must be signed in to change notification settings - Fork 133
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
Are results non-deterministic? #131
Comments
Yeah, order is not guaranteed as the underlying package used for globbing
We could maybe sort the results, but it's not clear what downsides that might have. @mrmlnc Is there a reason you're not just sorting the resulting array before returning it? |
The reason for the non-deterministic order is parallelism when working with the file system. The I have several reasons for this:
You can just sort the results if required without any problems. |
Thanks for the clarification. @sindresorhus, it may be helpful (for others) to write in README that results are non-deterministic. I assumed (my mistake) results are ordered until some of my tests failed very lately. As you indicated in your answer By the way, also @mrmlnc many thanks for |
@mrmlnc Does that apply only to the async API? Or does the return value of |
The synchronous API must return results in a deterministic order. I know of only one case where order can be broken: |
For #16767 Apparently globby's order is non deterministic: sindresorhus/globby#131 I wasn't able to reproduce in our tests but definitely saw the behaviour in the issue.
Hi,
I looked in docs and issues, but could not find an answer. Order of returned files of
globby
with same directory structure and and same glob patterns change from execution to execution.In one of my projects, some tests depend on order of returned files, and those tests fail:
90% of time (just observation, not instrumented)
vs.
10% of time
Is this expected behavior?
Thanks,
The text was updated successfully, but these errors were encountered: