-
-
Notifications
You must be signed in to change notification settings - Fork 948
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
[Regression]: ERROR Invalid string length (RangeError: Invalid string length) #7079
Comments
This is still happening. No communication, nothing. Something appears to have gotten merged - and then this was closed, without comment. I'm just sitting here with a broken package manager, having to use a many-releases-old pnpm version as a workaround. What's up with that? |
8.11.0 still b0rked. |
I'm facing the same issue with
|
Never mind, I think it was failing on something earlier from another change. I'm still hitting this once I get to |
We should fix it for sure but I can't reproduce the issue. This is probably the same issue as this one: #5056 Looks like using an object hash instead of JSON.stringify could be the solution but I wasn't able to break JSON.stringify yet to verify the fix. As a temporary fix, I think you can just disable side effects cache by setting side-effects-cache to |
Happening for me on 9.1.4; posting here my comment from #8072: I get this same error with 9.1.4, so ignore the 9.1.3 in the path in the error report. I've upgraded to 9.1.4 and tried again to find the same issue.
Modified that bit of code in the 9.1.4 transpiled JS to be:
And that outputs:
So looks like we're running into some very large strings here. Even if it were able to handle that, it seems like the lockfile would be a few hundred MB in size. That was with:
Running it with:
results in the same error, but it seems to happen later in the process. This time here's the output I get:
Happy to help debug some more if you tell me what variables you want to see, but unfortunately I'm not able to provide access to the specific repository where it's happening. If it helps here's my full config:
|
From the stacktrace it looks like the error happens because the lockfile is too big. |
That's why I think it's moreso related to #8072 than this particular issue. Coupled with my findings in my first comment on that issue, the graph being generated related to peer dependencies seems like it grows exponentially if you have a project with a lot of dependencies: In my case I have two repositories:
My guess is since there are so many peer dependency relationships here, it's really stressing the new peer dependency resolution algorithm and is causing the size of the lockfile to balloon out of control. The original performance issue I was experiencing was the time required to process the peer dependency graph to find cycles. That appears to have been fixed through optimization in 9.1.4, but the underlying issue of an extremely large peer graph still persists. To be sure, this was never an issue in v8 and running the installation still works in the smaller monorepo if I reinstall pnpm v8, so it must be related to the new peer dependency resolution. Though even when I disable |
Did some more digging and exported the string it's trying to append to the lockfile. Here's a snippet of it: These are our internal packages that all depend on one another. The standard-sets line is 100MB alone in size. Coincidentally, it also has the most peer dependencies of all of the packages included in that list. Some of the other packages that don't have as many peer dependencies are only 500KB in size, so this has to be growing exponentially somewhere. Looking at the lockfile PNPM v8 generated, it looks like 8 outputs essentially just a list of the peer dependencies instead of the entire graph of the peer dependencies like v9 does. Here's that same line inside a v8 lockfile (formatted to wrap for clarity):
Looking at the |
One line is 100MB? Can you attach the whole line? It shouldn't contain any private stuff, just the package names and versions. v8 did not resolve peer dependencies of peer dependencies correctly. Unfortunately, when a peer dependency has a peer dependency of its own, the resolution becomes really hard really fast. And to distinguish all the different combinations that could happen, the key becomes long. |
Here's a zip of the lockfile part for the package that's causing the issue. The 100MB line is with feature-standard-sets-react. The file should be ~530MB when extracted. Well, it compressed down to 6MB 😛 - so there's another giveaway that there seems to be some serious repetition going on. |
What about using a hash to represent the different combinations instead of listing all of them out? Unless you later parse that string of combinations (as I assume you do)? |
We could hash that. Although, a lot of additional hashing will make installation slower. What is the speed of installation at the moment in that workspace? |
I can time it later today when I'm at my machine but it's not terrible. Maybe 1 minute or so with a 15 second pause when doing this peer calculation math after building. |
Took 2 minutes, 41 seconds before running into the error. Tried again on Tried again on Looks like it works! 🎉 |
Unfortunately, this would be a breaking change... Unless maybe I make it a really big number. Does it work if you change 200 to 1000 here?
|
🚢 9.3.0 |
Last pnpm version that worked
8.7.0
pnpm version
These don't work:
8.7.4 and 8.7.5
Code to reproduce the issue
I don't have any specific or special code to reproduce it. It happens on any standard repo. It appears to be endemic to workspace-based repos...I think
To test it --> Use this
You can test this out on the following boilerplate (it happens here, at least on my machine):
https://github.com/antfu/vitesse
pnpm-workspace.yaml
packages/<something>
Expected behavior
Installation works without errors...we're just installing a set of packages, and it's not even a huge set of packages.
Actual behavior
Attempting to install the packages in my workspace, using
pnpm 8.7.4
Check current version of (working) pnpm
Run current working version of pnpm@8.7.0
Additional information
A regression? Okay...but of what?
I looked for any related issues, and found the following: #4949
The behavior I'm observing appears to be consistent with what's in this bug report, therefore I assume that this is a regression.
Node.js version
18.16.1
Operating System
macOS
The text was updated successfully, but these errors were encountered: