-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
load-actual and link.target setter cleanup #5376
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Member
wraithgar
commented
Aug 24, 2022
- fix: loadActual cleanup
- fix: link.target setter
While looking at the target setter for nodes, it seemed odd that we were making affordances for sometimes setting a promise as the target. After unraveling the code, it turns out this is impossible outside of tests, where we set environment variables to mimic that state. We were always awaiting the generation of links/nodes where appropriate. This commit inlines some code and cleans it up to the point where this fact could be verified, and then removes the now unneeded logic in loadActual that was trying to account for this. loadActual, an async function, now returns a promise that resolves to the tree, as a singleton. This maintains the use case commented on where buildIdealTree and reify can happen in parallel. This fixes a potential bug in reify (and likely others) which pass around this.idealTree as an object, and NOT a promise, even though before this refactor it can sometimes be a promise.
There were guards in place to protect when setting a promise as a target, which is not something the code actually does, which was discovered after unpacking load-actual. This removes those guards which are dangerous because either an attribute is a promise or it's not. Letting things access attributes as non-promises that are sometimes promises is dangerous.
commit messages tell the story. |
nlf
approved these changes
Aug 24, 2022
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is great, much more straight forward and clear!
This was referenced Sep 8, 2022
lukekarrys
added a commit
that referenced
this pull request
Apr 24, 2024
Arborist CI has started failing on `macos-latest` now that those runners default to `arm64` machines (aka Apple Silicon). I am able to reproduce the failures locally on a Macbook Pro M1. After spending some time debugging the issue I believe it has to do with the timing of `Node` vs `Link` creation. I was able to bisect and find #5376 which removed the ability for nodes to possibly take longer to create than their link targets. Going back to the commit before that PR the flaky test passes locally for me and fails starting with the first commit in that PR. I'm just running the offending test in a loop and seeing if it fails, so not a perfect metric. But when it fails, I get a failure at least 10% of the time. On the old commit I was able to run it 50x with no failures. Here's what I was running locally to observe failures: ```sh COUNT="0" while true; do COUNT=$((COUNT+1)) echo "Start $COUNT" if ! npm test -w workspaces/arborist --ignore-scripts -- test/arborist/load-actual.js --no-coverage -Rtap --grep selflink; then echo "Failed on run $COUNT" exit 1 fi done ``` This is definitely an edge case, but one I would like to fix in the future. Disabling this test is to temporarily get CI green while we release and make more substantial changes that are hard to do with CI flaking. We've had other issues with symlinks and I would feel much better knowing we have defined behavior in this specific case when tracking down future potential symlink bugs. One fix that worked locally is iterating over `node.target.children` sequentially instead of in `Promise.all`] but that is probably only a side effect of the dep ordering in the test. A fix will have to account for any order of links and node taking different amount of time. https://github.com/npm/cli/blob/c1152e9d2e325bc87176d3d9788605107d109b7b/workspaces/arborist/lib/arborist/load-actual.js#L337
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.