feat(excel): streaming reader for sheets too large for SheetJS - #20
Open
aandre35 wants to merge 1 commit into
Open
feat(excel): streaming reader for sheets too large for SheetJS#20aandre35 wants to merge 1 commit into
aandre35 wants to merge 1 commit into
Conversation
SheetJS loads each worksheet's XML as a single JS string and silently drops any sheet whose XML exceeds Node's ~0.5 GB max string length — which happens around Excel's ~1,048,576-row ceiling. The symptom is a misleading "Sheet <name> not found in workbook" error even though the sheet exists. Add an opt-in `.streaming()` mode on ExcelExtractionConfigBuilder (single-sheet only) that parses the target worksheet row-by-row with yauzl (random-access zip, independent of archive entry order) + saxes (streaming SAX). Memory stays bounded (~tens of MB) regardless of sheet size; verified on a 2.3 GB / 1,043,058-row worksheet at ~0.15 GB peak RSS. Preserves the in-memory reader's semantics: numberOfRowsToSkip, lowest-column stop rule, type coercion, and derived (variableName) fields. Wires the streaming path into FileStream (no in-memory pre-count) and bumps the package to 0.4.0. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Problem
A connector failed on a Lactel workbook with
Sheet WHALY_test_2 not found in workbookeven though the sheet exists. Root cause: that sheet runs to Excel's ~1,048,576-row ceiling (~2.3 GB of worksheet XML). SheetJS materializes each worksheet's XML as a single JavaScript string, and Node caps strings at ~0.54 GB, so SheetJS silently drops the oversized sheet fromworkbook.Sheetswhile keeping it inSheetNames. No amount of heap helps — it's a string-length limit.Change
Adds an opt-in streaming Excel reader:
.streaming()onExcelExtractionConfigBuilder(single-sheet extraction only) + astreaming?flag on the config type.rowGeneratorFromExcelSheet()(excel/stream-reader.ts) parses the target worksheet row-by-row usingyauzl(random-access zip — independent of archive entry order) +saxes(streaming SAX). It loads the small shared-strings table, then streams the worksheet, so memory stays bounded regardless of sheet size.FileStream(no in-memory pre-count;totalRowsstays undefined so progress logs omit the percentage).numberOfRowsToSkip, lowest-column "stop on empty" rule, type coercion, and derived (variableName) fields.exceljswas evaluated first but rejected: its streaming reader crashes nondeterministically depending on zip entry order (workbook.xmlposition), which is unsafe for arbitrary client files.Adds
yauzl+saxesas dependencies; bumps the package to 0.4.0.Verification
Follow-up
Consumers must bump to
@whaly/connector-sdk@^0.4.0once published. The Lactelfile-uploadsconnector has been updated to call.streaming()on itscircana_vmhconfig (separate repo).🤖 Generated with Claude Code