Conversation
A ~25 MiB builder config saved fine through PUT but crashed the CLI with RangeError: Maximum call stack size exceeded, and the following `flows config get` crashed the same way, so the flow was unreadable from the CLI. The crash is in the human renderer (src/lib/output.ts), which spread whole rendered subtrees into push() (argument-count overflow at ~100k array items) and recursed as deep as the JSON nests. - flows config get/update/validate: skip the human renderer under --json, as preview already does; --json now never touches the recursive path. - flows config get/update: print scalar fields plus a one-line config summary (screens, locales, bytes) instead of the raw blob; the full config stays in --json. - output.ts: append lines with a loop instead of push(...spread), cap recursion at 50 levels and fall back to a truncated JSON line (or a marker when JSON.stringify itself cannot serialize the subtree).
This branch has not been 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.
Problem
A ~25 MiB flow builder config saved fine through
adapty flows config update --config-file ..., but the CLI then crashed withRangeError: Maximum call stack size exceeded(exit 1). The nextadapty flows config geton that flow crashed the same way and printed nothing, so the flow was unreadable from the CLI. The write itself succeeded, so the crash reported a failure on a successful save.Root cause
The human pretty-printer in
src/lib/output.ts(renderObject/renderArrayItems) overflows the stack in two ways:lines.push(...renderArrayItems(...))spreads every rendered line as a function argument. V8 throws once a subtree renders to roughly 100k lines (a ~3 MiB config).JSON.parseon the response andJSON.stringifyon the request body handle the payload fine. Only the display layer crashes.printResponsealso ran under--json, because theflows configcall sites were not guarded bythis.jsonEnabled(), so there was no escape hatch.Changes
printResponseunder--jsoninflows config get,updateandvalidate, mirroringflows config preview.--jsonnow serializes through oclif only and never enters the recursive renderer.flows config get/update. It prints the scalar fields (updated_at,status,publication_status,transform_error,publication_error) plus one line forconfigwith screen count, locale count and byte size.--jsonstill returns the full payload unchanged.output.tsoverflow-proof as a backstop for every other command: append lines with a loop instead ofpush(...spread), cap recursion at 50 levels and print the rest of that subtree as a truncated single JSON line (or a marker whenJSON.stringifyitself cannot serialize it).Tests
test/lib/output.test.ts: renders a >5 MiB, 150k-item array and a 6000-level nested object and array throughprintResponsewithout throwing.test/commands/flows.test.ts:config getprints the summary and hides the blob in human mode, returns the exact DTO under--json, and survives a ~5 MiB config with 1000 nesting levels in both modes.pnpm build,pnpm lintandpnpm test(371 passing) are green.Not in scope:
--expected-updated-atstays a millisecond integer; the wire format and--jsonshape are unchanged.🤖 Generated with Claude Code