question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug] Link step when installing on a moderately sized monorepo is taking a very long time

See original GitHub issue
  • I’d be willing to implement a fix

Describe the bug

Yarn takes upwards of 9 minutes in the link step phase of a monorepo install. In one case it took 39 minutes.

During this time no logs or other useful information is output.

Related to the problems @haggholm had in #818

To Reproduce I am sure this is going to be a pain to reproduce however in my case:

  • Have a monorepo with 19 different packages, some depending on each other in their peerDeps and devDeps
  • Run yarn

I am attempting to create a non-private monorepo where this can be reproduced on.

Screenshots Screen Shot 2020-02-23 at 8 55 55 PM

Screen Shot 2020-02-23 at 8 56 33 PM

Environment if relevant (please complete the following information):

  • OS: OSX
  • Node version: 11.0.1
  • Yarn version: Running from source

Additional context

I found the traverse method found on this line frequently is taking a long amount of time:

https://github.com/yarnpkg/berry/blob/8b8483bc95f3e39e597c77087e61dc2c2fc21447/packages/yarnpkg-core/sources/Project.ts#L1141

It seemed to hang when processing a package that had a dependency on a common package in my monorepo.

Changing traverse(resolution, new Set(seenPackages)); to traverse(resolution, seenPackages); speeds everything up, taking only 46seconds, but of course this is fundamentally changing what this method is doing. I don’t have enough knowledge about what exactly this is trying to do to try and fix it myself.

Feel free to reach out for further information though or other ways of debugging what’s going wrong here. I’ll also try and create a reproduction repository.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
arcaniscommented, Feb 24, 2020

Even better, instead of computing the build hash through digest(A, B, C) (assuming that A depends on B which depends on C), we should instead compute it via digest(A, digest(B, digest(C))). This would allow us to cache in memory the intermediary results, so we’d never need to traverse the same package twice.

0reactions
arcaniscommented, Mar 6, 2020

I think this should be fixed with the latest improvements in master! (cf #1040) I’ll go ahead and close it, we can open another issue if there’s something else to do.

Read more comments on GitHub >

github_iconTop Results From Across the Web

The Case for Monorepos: A sane Workspace Setup (Part 2)
Learn how to setup dev tooling in a monorepo, run tasks efficiently, release multiple packages and overcome common DevOps challenges.
Read more >
The issue with Monorepos - Squash
Not only does it take a long time, but it also creates a lot of unnecessary trouble in either searching or editing.
Read more >
Is Monorepo for You? — 2020 - Bits and Pieces
An increase in PR size results in a long time for code review, with a large team it may require extra effort in...
Read more >
Forking, Fixing, & Using a Flutter (Monorepo) Package
Assuming you've determined there is indeed a bug and you're going to attempt to fix it, the first step is to fork the...
Read more >
Introduction to GitLab Flow
At any time, there is at most one branch for every issue. It is possible that one feature branch solves more than one...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found