Repository navigation
fix(parser): avoid Math.max spread on large files - #25
Merged
Merged
Conversation
Math.max(...rows.map(r => r.length)) passes one argument per row and throws Maximum call stack size exceeded in V8 somewhere between 100k and 200k rows, so large files failed to load and the merged export failed. A maxRowLength loop helper replaces the spreads in extractValidTableData and the merged export width, and the existing reduce in applyFilters.
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
maxRowLength(rows, min = 0)loop helperextractValidTableData: bothMath.max(...rows.map(r => r.length))calls use itmaxColsis areduceover blocks withmaxRowLength(block.rows)instead of nested spreadsapplyFiltersuses the same helper instead of its ownreduce(same result)Why
CSV-H1: spreading one argument per row into
Math.maxthrowsRangeError: Maximum call stack size exceededin V8 (Chrome, Edge, Node). A big export failed to load at all, and the merged export failed for a large blockChecks
bun run buildtsc --noEmit --strict --skipLibCheck --jsx react-jsxonsrc/main.tsx(no errors)parseCSVText+extractValidTableDatatranspiled withBun.Transpilerand run in Node (V8):Maximum call stack size exceededgit diff --check