Repository navigation
Fix IMSUM, IMPRODUCT and TEXTJOIN throwing RangeError for large ranges (HF-593) - #1901
Conversation
coerceComplexExactRanges and TEXTJOIN appended a range's values with push(...values), which passes one call argument per value. A range of about 125,000 cells exceeded the call stack and the RangeError escaped the recalculation. The values are now appended in a loop. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…r fix Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
hyperformula-docs | 7d85532 | Commit Preview URL Branch Preview URL |
Nov 19 2026, 10:51 AM |
There was a problem hiding this comment.
Note
Medium risk: Small, semantically equivalent refactor (spread push → loop) on the interpreter's argument-coercion hot path for IMSUM/IMPRODUCT/TEXTJOIN; behaviour for previously working inputs is unchanged, so the blast radius is limited to the newly un-crashed large-range cases.
Full review: 1 potential issue(s).
hyperformula/src/interpreter/ArithmeticHelper.ts:511
manyToNumbers still spreads range values, fix incomplete vs new rule
Medium severity
The PR fixes the push(...values) stack overflow in coerceComplexExactRanges and TEXTJOIN, and adds a dev-docs rule (INTERPRETER.md L23: "Never spread a range's values into a call"), but manyToNumbers — the shared path behind coerceNumbersExactRanges and coerceNumbersCoerceRangesDropNulls — still does expandedVals.push(...arr). Any built-in function coercing a large range through those helpers (e.g. SUMSQ-style exact-range coercion) still throws the same uncaught RangeError: Maximum call stack size exceeded out of the recalculation for ranges of roughly 125,000+ values, so the class of bug the PR claims to fix and codifies as a repository rule remains live in the same file it edited.
Suggestion: Apply the same loop append in manyToNumbers (replace expandedVals.push(...arr) with a for loop), or explicitly scope the new dev-docs rule and note the remaining call sites as follow-ups.
Want a deeper review? Comment /review improve on its own line: a full review of the latest commit with an extra fix-oriented pass (about 2x the cost).
# Conflicts: # CHANGELOG.md
Performance comparison of head (7d85532) vs base (91f4681) |
There was a problem hiding this comment.
Note
Medium risk: Touches core interpreter coercion paths (ArithmeticHelper, TextPlugin) used by IMSUM/IMPRODUCT/TEXTJOIN/CONCAT recalculation, but the changes are narrow loop replacements covered by base-vs-head runs; this incremental push only edits copyright headers.
Incremental review: 1 potential issue(s).
hyperformula/src/interpreter/plugin/TextPlugin.ts:195
CONCATENATE still spreads range values, throws RangeError on large ranges
Medium severity
CONCATENATE is declared with expandRanges: true, so a range argument is expanded into one callback argument per cell. The callback then does ''.concat(...args), spreading every value into a single call — exactly the pattern this PR removes from coerceComplexExactRanges and textjoin and forbids in the new dev-docs rule. For a range of roughly 125,000 cells or more (e.g. =CONCATENATE(A1:D40000)), this throws the same uncaught RangeError: Maximum call stack size exceeded that escapes recalculation and fails the triggering CRUD call, so the fix is incomplete for the CONCAT family.
Suggestion: Build the result with a loop, e.g. iterate args and append each string to an accumulator (or reuse the loop-based approach already implemented in concat/textjoin), instead of ''.concat(...args).
Want a deeper review? Comment /review improve on its own line: a full review of the latest commit with an extra fix-oriented pass (about 2x the cost).
Tobiadefami
left a comment
There was a problem hiding this comment.
The 160,000-cell specs throw RangeError on develop and pass here, also through SEQUENCE and with an error inside the range. Results for small ranges are unchanged.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #1901 +/- ##
========================================
Coverage 97.51% 97.51%
========================================
Files 210 210
Lines 17133 17135 +2
Branches 3924 3890 -34
========================================
+ Hits 16707 16709 +2
Misses 418 418
Partials 8 8
🚀 New features to boost your workflow:
|
### Context The PR removes the `gpl-v3` license key from the engine, the tests and the docs. - **Why:** HyperFormula 4.0 is proprietary only, but `gpl-v3` still unlocked everything. - **What changed:** - `hyperformula/src/`: `gpl-v3` reads as invalid. On `handsontable.com` and its one-label subdomains, the license check is skipped, so the live docs examples run without a key. - Console messages for a missing, invalid or expired key use Handsontable's text, with the expiry day in two digits. A key without a HyperFormula entry prints the invalid-key warning. - Tests, `check-file.js`, the docs build and the formula editor demo use an internal test key. Its text says it is not licensed for production. One constant per consumer; the private suite's `unit/license/test-license-key.spec.js` fails if they differ, or if the key appears anywhere else, in this repository or the private suite. - Docs previews get the test key in the live example scripts only, and only on an explicit opt-in (`DOCS_TEST_LICENSE_KEY=true`, set by `npm run preview:cf`), never for `master`. Without the opt-in, a build fails if the key is anywhere in its output, and `npm run deploy:cf` refuses a built site that holds it. - "Open in StackBlitz" projects show an "add your license key" notice when the engine reports a missing or invalid key. - About 190 code examples (JSDoc, 12 docs examples, guides, READMEs) show the commented-out key placeholder. - `license-key.md` and `licensing.md` are rewritten, `migration-from-3.x-to-4.0.md` leads with the license change and links #1888, and "open source" wording is gone from current pages. - `dev-docs/SENSITIVE-INFORMATION.md`: two exceptions to the rule, the internal test license key and links to Claude Code sessions. - **Result:** no current code, test or page uses or offers `gpl-v3`. Deviations from Handsontable: | Area | Handsontable | HyperFormula | |---|---|---| | Blocked state | Lock screen | `#LIC!` and `LicenseCapabilityMissingError` | | Placeholder URL | `handsontable.com/pricing/` | `handsontable.com/pricing/?tab=hyperformula` | | Licensing page | Lists license types | Proprietary, pricing link, sales email | | Preview key | Vite transform on example modules, at build time | Rewrite of inline example scripts in the built site, by the preview deploy command. Same opt-in, `DOCS_TEST_LICENSE_KEY=true` | | Domain check | Hex-encoded regex | Plain regex, same pattern | | `#LIC!` and error messages | None (lock screen) | `#LIC!` and `LicenseCapabilityMissingError` texts give `sales@handsontable.com` | Messages follow Handsontable exactly, so they differ from the HyperFormula key spec: L1–L3 are longer, and M7 and M8 print as warnings. They also differ from HOT-15706, which asked for docs links: like Handsontable's, they have no links, and give `support@handsontable.com` or `sales@handsontable.com`, or say to purchase a license. The trial and subscription messages name those licenses, as Handsontable's do. ### How did you test your changes? Paired branch in `hyperformula-tests`: `feat/hot-15706-remove-gpl`. - Lint: 0 errors. Karma (Chrome): 8354 passed. UI e2e and bundle check: passed. - Jest, after merging `develop` (with #1786 and #1901): 547 suites, 9,090 passed, 3 skipped, 0 failed. CI is green on the later `develop` merges. - Docs: a build without the opt-in holds no key. `inject-preview-license-key.mjs` refuses without the opt-in and for `master`, and with it writes the key into the 12 example scripts only. Running it again on an injected build changes nothing. `deploy:cf` refuses a site after `preview:cf` has written the key into it. - Preview pages against the 3.5.0 engine in Chromium: every example runs, with no license message. The StackBlitz notice shows for the basic-usage example on 3.5.0 with no key. ### AI assistance Claude Code wrote the code, tests and docs. ### Compatibility with Excel and Google Sheets Not applicable. ### Public API changes - The `licenseKey` value `gpl-v3` is invalid. - License console messages have new text. - The `#LIC!` and `LicenseCapabilityMissingError` messages end with `sales@handsontable.com`: for a missing, invalid or expired key, and for a function or feature the key does not include. ### Out of scope and follow-ups - The 0.6, 1.x and 2.x migration guides keep `gpl-v3`: they describe those versions. - The vendored key parser still mentions `gpl-v3` and GPL. The upstream fix is in handsontable/license-key#16; it reaches this repository with the next re-vendor. - `release-notes.md` is generated from the changelog at release time. `### Changed` comes first under `[Unreleased]`, so the generated 4.0.0 section leads with the license change. - The docs deploy must wait until 4.0.0 is on the CDN. Until then, production pages run 3.5.0, which has no domain skip. - `npm run docs:dev` can't give the live examples a key; `docs/README.md` gives the workaround. - `licenseKeyValidityState` stays internal; making it public is a separate API change. ### Types of changes - [x] Breaking change (existing functionality no longer works as before) – agreed with the maintainers - [ ] New feature or improvement (a non-breaking change that adds functionality) - [ ] Bug fix (a non-breaking change that fixes an issue) - [ ] Additional language file, or a change to an existing language file (translations) - [x] Change to the documentation ### Related issues 1. HOT-15706 2. #1888 ### Checklist - [x] My pull request meets the [Definition of Done](https://github.com/handsontable/hyperformula/blob/develop/dev-docs/DEFINITION-OF-DONE.md). External contributors: see also [Contributing to HyperFormula](https://handsontable.com/docs/hyperformula/guide/contributing.html). - [ ] I have signed the [Contributor License Agreement](https://goo.gl/forms/yuutGuN0RjsikVpM2). - [ ] I read my own diff end to end before requesting a review. - [x] I added a [CHANGELOG.md](https://github.com/handsontable/hyperformula/blob/develop/CHANGELOG.md) entry, written by [the changelog rules](https://github.com/handsontable/hyperformula/blob/develop/dev-docs/DOC-STANDARDS.md#the-changelog) – or none is needed (docs, tests or tooling only). - [x] I updated the documentation and JSDoc to match the change. - [x] Breaking change only: I added a section to the migration guide. - [x] I updated the `dev-docs/` pages this change affects – or none needed it. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01KD7f9XHrxQxDeC5G3HMDM1 --------- Co-authored-by: Claude <noreply@anthropic.com>
Context
IMSUM,IMPRODUCTandTEXTJOINthrew an uncaughtRangeError: Maximum call stack size exceededfor a range of about 125,000 cells or more (for example=IMSUM(A1:D40000)). The error escaped the recalculation, sobuildFromArrayor the CRUD call that triggered it failed. The cell did not get a value or an error value.Cause:
ArithmeticHelper.coerceComplexExactRanges, used byIMSUMandIMPRODUCT, andTEXTJOINappended a range's values withpush(...values). That passes one call argument per value, and the call stack runs out at roughly 125,000 values on Node 24. The values are now appended in a loop. Results for ranges that worked before do not change.The rule is also added to
hyperformula/dev-docs/INTERPRETER.md: never spread a range's values into a call.How did you test your changes?
fix/hf-593-range-spreadinhyperformula-testsadds a 160,000-cell case to the specs forIMSUM,IMPRODUCTandTEXTJOIN. Each case asserts the value Excel returns for the same input, and theIMPRODUCTandTEXTJOINcases put a distinct value in the last cell, so a range that is read only in part fails.ArithmeticHelperloop fails theIMSUMandIMPRODUCTcases withRangeError(2 failed, 47 passed). Reverting theTEXTJOINloop fails theTEXTJOINcase (1 failed, 48 passed).tsc --noEmit,npm run lintand the full Jest suite with the private suite attached:tscexit 0, lint 0 errors, Jest 529 suites passed (7,277 tests passed, 3 skipped) on engine860aabef2with testsf1a6edb1e.developcovered 116 formulas: the three functions at sizes from 1,000 to 1,000,000 values, both as cell ranges and asSEQUENCEarrays, plus small inputs.RAND()inside an argument is still evaluated once.AI assistance
Claude Code (Claude Opus 5.5) wrote the code change, the tests, the changelog entry, the dev-docs line and this description. It also ran the Excel measurements. A maintainer reviews it like any other change.
Compatibility with Excel and Google Sheets
Excel results were measured in Excel Online. The 160,000 values come from a spilled
SEQUENCE(1, 2, 3, 4 in every row, or 1 everywhere; the last cell typed in where it differs). Google Sheets was not checked.develop→ this branch)=IMSUM(A1:D40000), 1, 2, 3, 4 in every row400000RangeError→400000=IMPRODUCT(A1:D40000), 1 in every cell1RangeError→1=IMPRODUCT(A1:D40000), 1 in every cell butiin D40000iRangeError→i=TEXTJOIN("-",TRUE,B1:E40000,"x","y"), B1:E40000 emptyx-yRangeError→x-y=TEXTJOIN("-",TRUE,B1:E40000,"x","y"), B1:E40000 empty butzin E40000z-x-yRangeError→z-x-y=IMSUM(SEQUENCE(40000,4,1,0))160000RangeError→160000=TEXTJOIN("",TRUE,A1:D40000), 1, 2, 3, 4 in every row (160,000 characters)#CALC!RangeError→#VALUE!=IMPRODUCT(A1:D40000), 1, 2, 3, 4 in every row (overflows)#VALUE!RangeError→#NUM!=IMPRODUCT("1e200","1e200")#VALUE!#NUM!→#NUM!=LEN(TEXTJOIN("",TRUE,SEQUENCE(32767,1,1,0)))3276732767→32767HyperFormula spells the boolean as
TRUE(). The last three rows show error types that differed from Excel before this change and still differ. They are listed under follow-ups.Public API changes
None.
Out of scope and follow-ups
TEXTJOINresult is longer than 32,767 characters, HyperFormula returns#VALUE!and Excel returns#CALC!. Add the #CALC! error type (HF-134) #1889 changes it.IMPRODUCTreturns#NUM!and Excel returns#VALUE!, for any range size. Follow-up task: HF-600.manyToNumbersinArithmeticHelperhas the same spread. It makesSKEWand the other functions that use it throw for 160,000 cells. Add KURT, MODE.SNGL, PERCENTRANK.EXC and TRIMMEAN functions (HF-427, HF-423, HF-422, HF-426) #1800 replaces it with a loop.Interpreter: HF-577.RangeErroroutside functions. Inserting 200,000 rows at once withaddRowsthrows inDenseStrategy, and a 200,000-cell circular reference throws inTopSort. Follow-up task: HF-601.Types of changes
Related issues
Checklist
dev-docs/pages this change affects – or none needed it.🤖 Generated with Claude Code