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

[Regression]:  ERROR  Invalid string length (RangeError: Invalid string length) #7079

Open
armenr opened this issue Sep 11, 2023 · 5 comments

Comments

@armenr
Copy link

armenr commented Sep 11, 2023

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

  • Just add a pnpm-workspace.yaml
  • move everything into into packages/<something>
  • try to run an installation

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

❯ npx pnpm@latest i
Need to install the following packages:
  pnpm@8.7.4
Ok to proceed? (y) Y
Scope: all 4 workspace projects
 ERROR  Invalid string length

RangeError: Invalid string length
    at JSON.stringify (<anonymous>)
    at calcDepState (/Users/x3r0/.npm/_npx/de6729f694090229/node_modules/pnpm/dist/pnpm.cjs:122538:29)
    at /Users/x3r0/.npm/_npx/de6729f694090229/node_modules/pnpm/dist/pnpm.cjs:124082:69

Check current version of (working) pnpm

❯ pnpm --version
8.7.0

Run current working version of pnpm@8.7.0

❯ pnpm i
Scope: all 4 workspace projects
../../amplify/backend/function/arangoTest/node_modules/.pnpm/esbuild@0.19.2/node_modules/esbuild: Running postinstall script, done in 137ms
node_modules/.pnpm/simple-git-hooks@2.9.0/node_modules/simple-git-hooks: Running postinstall script, done in 93ms
node_modules/.pnpm/esbuild@0.18.20/node_modules/esbuild: Running postinstall script, done in 133ms
node_modules/.pnpm/cypress@13.1.0/node_modules/cypress: Running postinstall script, done in 307ms
node_modules/.pnpm/sharp@0.32.5/node_modules/sharp: Running install script, done in 1.1s
node_modules/.pnpm/vue-demi@0.14.6_vue@3.3.4/node_modules/vue-demi: Running postinstall script, done in 67ms
node_modules/.pnpm/json-editor-vue@0.10.15_vanilla-jsoneditor@0.17.10_vue@3.3.4/node_modules/json-editor-vue: Running preinstall script, done in 34ms
node_modules/.pnpm/json-editor-vue@0.10.15_vanilla-jsoneditor@0.17.10_vue@3.3.4/node_modules/json-editor-vue: Running postinstall script, done in 33ms
. postinstall$ npx simple-git-hooks
│ [INFO] Successfully set the pre-commit with command: npx lint-staged
│ [INFO] Successfully set all git hooks
└─ Done in 476ms
Done in 6.2s

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

@armenr
Copy link
Author

armenr commented Dec 8, 2023

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?

@armenr
Copy link
Author

armenr commented Dec 8, 2023

8.11.0 still b0rked.

@samtsai
Copy link

samtsai commented Jan 23, 2024

I'm facing the same issue with 8.14.3:

[2024-01-23T15:42:09.746Z]  ERROR  Invalid string length
[2024-01-23T15:42:09.746Z] 
[2024-01-23T15:42:09.746Z] RangeError: Invalid string length
[2024-01-23T15:42:09.746Z]     at JSON.stringify (<anonymous>)
[2024-01-23T15:42:09.746Z]     at calcDepState (/home/builder/.cache/node/corepack/pnpm/8.14.3/dist/pnpm.cjs:124197:29)
[2024-01-23T15:42:09.746Z]     at /home/builder/.cache/node/corepack/pnpm/8.14.3/dist/pnpm.cjs:125690:69

@samtsai
Copy link

samtsai commented Jan 23, 2024

I was able to get further with pnpm install --fix-lockfile

Never mind, I think it was failing on something earlier from another change. I'm still hitting this once I get to pnpm install -r --offline step.

@zkochan
Copy link
Member

zkochan commented Jan 23, 2024

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 false.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Priority
Development

No branches or pull requests

3 participants