fix: prevent portal generate hang on Node 22+ (replace extract-zip with adm-zip)#283
Merged
Merged
Conversation
extract-zip's yauzl/fd-slicer read streams for STORED zip entries never emit `end` on Node 22+, so unArchive never resolves even after every file has been written; the event loop then drains with a pending top-level await and the CLI exits with code 13 (reproduced in CI on Node 24). Replace extract-zip with adm-zip's synchronous extraction (no per-entry streams), keeping the existing file-count/size guards. Removes the now-unused extract-zip dependency. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Shield-Jaguar
approved these changes
Jun 10, 2026
saeedjamshaid
added a commit
that referenced
this pull request
Jun 10, 2026
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
On Node 22+ (reproduced in GitHub Actions on Node 24),
apimatic portal generateprintsPortal generated successfully.and then crashes:Verified via runner logs (
NODE_DEBUG+ step markers + abeforeExitactive-resources dump): the download succeeds and every portal file is written to disk — the hang is inZipService.unArchive.Root cause
extract-zip@2.0.1extracts each entry viaawait pipeline(readStream, writeStream)and only reads the next entry once that resolves; the whole op resolves on yauzl's'close'. yauzl2.10builds STORED entries' read streams on the unmaintainedfd-slicer@1.1.0, and on Node 22+ those streams deliver every byte but never emitend. So the last entry'spipelinenever resolves →readEntry()is never called again →'close'never fires →unArchive's promise stays pending forever, even though the files are already written. The event loop drains with the top-levelawait execute()still pending → exit 13. (The nested STORED SDK.zipinside the portal is the entry that trips it.)active resources at beforeExit: [ 'PipeWrap', 'PipeWrap' ](only stdout/stderr) confirmed a dangling promise rather than an I/O stall.Fix
Replace
extract-zipwithadm-zipinZipService.unArchive. adm-zip extracts synchronously (extractAllTo) with no per-entry read streams — nofd-slicer, noend-event handshake — eliminating this class of hang. TheMAX_FILES/MAX_SIZEguards are preserved, and adm-zip sanitizes entry paths internally (zip-slip protection). Removes the now-unusedextract-zipdependency (and its transitiveyauzl/fd-slicer).Testing
Confirmed green on Node 24 via a dedicated GitHub Actions harness installing the built tarball: the portal now generates, saves, and the process exits 0.