这是indexloc提供的服务,不要输入任何密码
Skip to content

Add test to ensure relevant fields are sorted #2064

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

Merged
merged 1 commit into from
Sep 23, 2022

Conversation

gsoltis
Copy link
Contributor

@gsoltis gsoltis commented Sep 23, 2022

  • sort array fields on turbo.json
  • add test to ensure we are sorting fields used for hashing

Fixes #2029

@gsoltis gsoltis requested a review from a team as a code owner September 23, 2022 17:30
@vercel
Copy link

vercel bot commented Sep 23, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
turbo-site ✅ Ready (Inspect) Visit Preview Sep 23, 2022 at 5:30PM (UTC)

@nathanhammond
Copy link
Contributor

This doesn't make sense to me. I'm confused why any of this needs to be sorted when in multiple runs (without touching turbo.json) we should still get consistent ordering.

To my knowledge we're not doing anything that inserts asynchronous behavior into the processing of these values.

@gsoltis
Copy link
Contributor Author

gsoltis commented Sep 23, 2022

@nathanhammond not everything was non-deterministic, but the test is to help ensure it stays that way. The non-determinism that we have is coming from the Set implementation. It's a map under the hood, and Go's map iteration is intentionally random, so when we convert back to a list, it's in a random order.

@nathanhammond
Copy link
Contributor

Ah, good catch on Set being the guilty party. It makes sense to provide no guarantees about map iteration order but is also an annoying footgun coming from a JavaScript background. (Added to my mental list of "fun" Go things.)

@nathanhammond
Copy link
Contributor

Also, a bit surprised that map iteration is random with the same values in the map from a single-threaded use. That implies to me it's an actively randomized iteration.

@gsoltis
Copy link
Contributor Author

gsoltis commented Sep 23, 2022

@nathanhammond as a bonus: serializing a map to a string is deterministic. They sort it in the String() implementation. The hashing we do relies on that, it's hashing the string representation of all the maps it finds.

@gsoltis
Copy link
Contributor Author

gsoltis commented Sep 23, 2022

actively randomized iteration

Yes, it is intentionally actively randomized

@nathanhammond
Copy link
Contributor

This calls for a 1.5.3. sigh

@gsoltis gsoltis merged commit 18603a5 into main Sep 23, 2022
@gsoltis gsoltis deleted the gsoltis/fix_pipeline_sorting branch September 23, 2022 18:15
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

Successfully merging this pull request may close these issues.

Always getting "cache miss" in a simple lint task
2 participants