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

fix(plugin-essentials): handle aliased dependencies on dedupe #6527

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

BasixKOR
Copy link
Contributor

@BasixKOR BasixKOR commented Sep 26, 2024

What's the problem this PR addresses?

I wasn't able to reliably reproduce the problem but I think you can see what was the issue from the patches.

When running a dedupe on a project with aliased dependencies (usually esbuild and esbuild-wasm for us), we experienced Yarn abruptly stopping the dedupe process with this error message:

Assertion Error: The package ([hash]) should have been registered

The hash depends on the resolution but I believe it is happening because Yarn is trying to find a version of aliased dependency on original package (like trying to find esbuild-wasm on esbuild idents).

Fixes #6176.

...

How did you fix it?

Instead of trusting the descriptor's ident, dedupeUtils will now look up the project.originalPackages first to find potentially aliased packages. I tried using project.storedPackages first but it was empty on runtime.

...

Checklist

  • I have set the packages that need to be released for my changes to be effective.
  • I will check that all automated PR checks pass before the PR gets reviewed.

@arcanis
Copy link
Member

arcanis commented Oct 15, 2024

I'm not certain about this fix without a regression test, as I don't quite understand the issue - from what I see we're iterating over all resolutions and saving them into locatorsByIdent - so, for the assertion to fail, it means that we must have something in storedDescriptors that doesn't have a key in storedResolutions. Why does that happen?

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.

[Bug?]: The yarn dedupe command fails if there is esbuild package in the workspace package.json
2 participants