[Bug]: An array literal with a large array element throws "Maximum call stack size exceeded"
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 74/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- node.js, typescript
Research direction
Start with Interpreter.ts and the ARRAY branch of Interpreter.evaluateAst at the listed lines 266, 269, 278, and 280. Check how large arrays are passed to push() and run the relevant evaluator tests with the supplied 40,000-row formula. Done means the array literal evaluates without a RangeError and the formula cell can be read.
Written by the indexing model from the issue text.
Description
Description
An array literal with a large array as an element throws a RangeError from buildFromArray and setCellContents:
const data = Array.from({length: 40000}, () => [1])
data[0].push('=SUM({VSTACK(A1:A40000,A1:A40000,A1:A40000,A1:A40000)})')
HyperFormula.buildFromArray(data, {licenseKey: 'gpl-v3'})
// RangeError: Maximum call stack size exceeded
Without the braces, =SUM(VSTACK(A1:A40000,A1:A40000,A1:A40000,A1:A40000)) returns 160000, as the equivalent formula does in Microsoft Excel Online. In Node.js 22 the error starts at about 125,000 rows or columns in one element. After it is thrown by setCellContents, the formula is stored, but reading the cell throws Value of the formula cell is not computed.
Cause: the ARRAY branch of Interpreter.evaluateAst spreads element arrays into push() (Interpreter.ts:266, :269, :278 and :280). Each spread passes one argument per row or value, and large arrays exceed the JavaScript engine's limit on the number of arguments in a call.
Expected: the array literal is built for any size that the other array functions accept.
Video or screenshots
N/A
Demo
Code snippet in the description.
HyperFormula version
3.5.0 (also develop at ec7512d21)
Your framework
None (Node.js)
Your environment
Node.js 22.23.4 on Linux
- Dominant language
- TypeScript
- Stars
- 2.8k
- Forks
- 175
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 22
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from handsontable/hyperformula
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
handsontable/hyperformula#1879 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
handsontable/hyperformula#1803 ·
Maintainers usually reply within 1 day
-
numberToSimpleDate returns day 0 for 31 December of some years when leapYear1900 is truePossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
handsontable/hyperformula#1793 ·
Maintainers usually reply within 1 day
-
Bug
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
handsontable/hyperformula#1745 ·
Maintainers usually reply within 1 day
-
Bug Impact: Low
Difficulty 1/5 1-3 hours Newbie friendliness 68/100
handsontable/hyperformula#1641 ·
Maintainers usually reply within 1 day
All issues in handsontable/hyperformula
Similar issues
-
area:frontend kind:bug priority:p2 ready
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
RunestoneInteractive/rs#1661 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
capricorn86/happy-dom#2594 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
ehmpathy/rhachet-roles-ehmpathy#1294 ·
Maintainers usually reply within 1 day