[Bug]: An array literal with a large array element throws "Maximum call stack size exceeded"

Aperta
#1,878 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
74/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
node.js, typescript
Ambito
backend, data

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Bug
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

Lingua principale
TypeScript
Stelle
2.8k
Fork
175
Merge medio
2g 5h
PR unite (30g)
23

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di handsontable/hyperformula

Tutte le issue di handsontable/hyperformula

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.