fix(cli): reduce memory usage during SDK generation by skipping dynamic IR#12029
Open
tstanmay13 wants to merge 5 commits intomainfrom
Open
fix(cli): reduce memory usage during SDK generation by skipping dynamic IR#12029tstanmay13 wants to merge 5 commits intomainfrom
tstanmay13 wants to merge 5 commits intomainfrom
Conversation
…ic IR Co-Authored-By: tanmay.singh@buildwithfern.com <tstanmay13@gmail.com>
Contributor
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Co-Authored-By: tanmay.singh@buildwithfern.com <tstanmay13@gmail.com>
Co-Authored-By: tanmay.singh@buildwithfern.com <tstanmay13@gmail.com>
Co-Authored-By: tanmay.singh@buildwithfern.com <tstanmay13@gmail.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.
Description
Refs: Slack thread from @tstanmay13
Fixes JavaScript heap out of memory errors during SDK generation for large APIs when upgrading from CLI 0.51.28 to 3.57.0.
Root Cause: The dynamic IR (used for dynamic snippets) was being generated as part of the main IR generation phase. For large APIs, this duplicates significant amounts of data and causes memory pressure (~4GB heap usage before crash).
Solution 1: Added a
skipDynamicIrparameter to skip dynamic IR generation during the main IR generation phase for remote SDK generation. The dynamic IR is still generated separately when needed for uploading to FDR.Solution 2: Automatically increase Node.js heap size to 8GB. The CLI now detects when the heap limit is below 8GB and re-spawns itself with
--max-old-space-size=8192to prevent out-of-memory errors.Link to Devin run: https://app.devin.ai/sessions/a0edfc74953f442aafab5dde8ced88cc
Requested by: @tstanmay13
Changes Made
skipDynamicIroptional parameter togenerateIntermediateRepresentationfunctionskipDynamicIr: truefor remote SDK generation inrunRemoteGenerationForGenerator.tsuploadDynamicIRForSdkGenerationcli.tsusingv8.getHeapStatistics()andspawnSyncFERN_HEAP_INCREASEDenv var to prevent infinite re-spawn loopsversions.ymlwith both fixesTesting
pnpm run check)Human Review Checklist
spawnSyncdoesn't cause issues on different platforms (Windows, macOS, Linux)dynamicfield from the IR directlyskipDynamicIr: true)