handsontable / hyperformula

HyperFormula is an open-source headless spreadsheet for business web apps. It comes with over 400 formulas, CRUD operations, undo-redo, clipboard support, and sorting.
https://hyperformula.handsontable.com/
Other
1.9k stars 108 forks source link

[Bug]: `Maximum call stack size exceeded` when adding a row to a huge spreadsheet with formulas #1332

Closed sequba closed 6 months ago

sequba commented 8 months ago

Description

Code that produces this issue:

  it('handles huge spreadsheet', () => {
    const rowsCount = 1048576 // 2^20

    const sheet = []
    sheet.push(['1', '2', '3', '0', '0'])

    let prev = 1

    while (prev < rowsCount) {
      const rowToPush = [
        `${prev + 1}`,
        '2',
        '=3*5',
        `=A${prev}+D${prev}`,
        `=SUM($A$1:A${prev})`,
      ]

      sheet.push(rowToPush)
      ++prev
    }

    const engine = HyperFormula.buildFromArray(sheet, { maxRows: rowsCount*2 })

    expect(() => engine.addRows(0, [2000, 1])).not.toThrow()
  })

Originally reported by @BrianHung in https://github.com/handsontable/hyperformula/pull/1321

image

HyperFormula version

2.6.0

Your environment

AMBudnik commented 6 months ago

Closed as solved and released in HyperFormula 2.6.1. List of all the changes https://github.com/handsontable/hyperformula/releases/tag/2.6.1