berry icon indicating copy to clipboard operation
berry copied to clipboard

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

Open BasixKOR opened this issue 1 year ago • 1 comments

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

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

BasixKOR avatar Sep 26 '24 21:09 BasixKOR

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?

arcanis avatar Oct 15 '24 23:10 arcanis