Skip to content

Can't create array larger than 2**26 items #58197

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

Open
julienp opened this issue May 6, 2025 · 4 comments
Open

Can't create array larger than 2**26 items #58197

julienp opened this issue May 6, 2025 · 4 comments
Labels
v8 engine Issues and PRs related to the V8 dependency. v24.x v24.x v24.x Issues that can be reproduced on v24.x or PRs targeting the v24.x-staging branch.

Comments

@julienp
Copy link
Contributor

julienp commented May 6, 2025

Version

v24.0.0

Platform

Darwin macbook-pulumi.local 24.4.0 Darwin Kernel Version 24.4.0: Fri Apr 11 18:33:47 PDT 2025; root:xnu-11417.101.15~117/RELEASE_ARM64_T6030 arm64

Subsystem

No response

What steps will reproduce the bug?

Works:

Array.from("a".repeat(2**26))

Fails:

Array.from("a".repeat(2**26+1))
Uncaught RangeError: Invalid array length
    at Array.from (<anonymous>)

In v22.15.0 this works fine.

How often does it reproduce? Is there a required condition?

Always

What is the expected behavior? Why is that the expected behavior?

It should be possible to create arrays with 2**32 elements.

What do you see instead?

RangeError: Invalid array length

Additional information

No response

@juanarbol juanarbol added the v24.x v24.x v24.x Issues that can be reproduced on v24.x or PRs targeting the v24.x-staging branch. label May 6, 2025
@ljharb
Copy link
Member

ljharb commented May 6, 2025

There's nothing in the language spec that requires engines to have an array that long; however, Array.from({ length: 67108865 }) also fails in both node 24 and chrome, so it might be a v8-specific regression?

@juanarbol juanarbol added the v8 engine Issues and PRs related to the V8 dependency. label May 6, 2025
@juanarbol
Copy link
Member

It is definitely a V8 engine issue.

@juanarbol
Copy link
Member

juanarbol commented May 6, 2025

I think there is a misunderstanding here.

"a".repeat(kTimes) returns a single string with "a....aaaa-kTimes"; that is a single element.

The issue is not about the number of elements but its size in memory.

NVM, I think I found the issue from the V8 engine.

v8/v8@0c36aff

That commit just messes around with the Array length and it was introduced to the V8 v13.x-series

@RafaelGSS
Copy link
Member

Maybe related https://github.com/RafaelGSS/nodejs-bench-operations/actions/runs/14866441608/job/41744580099. This benchmark runs successfully on all previous Node.js versions except v24.

domenic pushed a commit to jsdom/jsdom that referenced this issue May 8, 2025
* Remove the fail-node18 failure reason, and mark those tests as passing now.
* Add fail-lt-node24 failure reason, and use it on Float16Array tests.
* Tweak the timeout-with-gc test to use an array size which is compatible with Node.js v24. (Possibly related to nodejs/node#58197.)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
v8 engine Issues and PRs related to the V8 dependency. v24.x v24.x v24.x Issues that can be reproduced on v24.x or PRs targeting the v24.x-staging branch.
Projects
None yet
Development

No branches or pull requests

4 participants