Repository navigation
core(gather): fix broken cycle detection in recurse functions - #17173
Merged
connorjclark merged 1 commit intoAug 24, 2026
Merged
Conversation
Both recursiveObjectEnumerate (trace-elements gatherer) and recursiveReplaceLocalizableStrings (trace-engine-result) guard against circular references with `seen.has(seen)`, which can never be true since a Set cannot contain itself. The guard was dead code, so any circular reference in trace-engine insight data caused infinite recursion and a stack overflow that takes down the whole run. Check `seen.has(obj)` instead so the visited set actually short-circuits cycles. Add regression tests that crash on the old code and pass now.
connorjclark
approved these changes
Aug 24, 2026
Collaborator
|
yup, thanks! |
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.
Summary
recursiveReplaceLocalizableStrings(core/computed/trace-engine-result.js:136) andrecursiveObjectEnumerate(core/gather/gatherers/trace-elements.js:101)seen.has(seen), which is alwaysfalse(a Set can't contain itself), so theseenset was dead codeseen.has(obj), revisits short-circuit and circular insight data no longer causesMaximum call stack size exceededWhy it matters
Both functions walk trace-engine insight models on every run. Trace-engine data is graph-like (parent/child back-references), so a single circular reference currently crashes the entire audit run with a raw stack overflow instead of a catchable error.
Tests
core/test/computed/trace-engine-result-test.js: circular object passed tolocalizeObjectno longer overflows; nestedi18nIdobjects still localizecore/test/gather/gatherers/trace-elements-test.js: circular insightmodelingetTraceEngineElementsreturns cleanlymainand pass with the fixyarn type-checkandyarn lintclean;update:sample-jsonproduces no relevant diffsNote: repo style appends (#NNNN) to commit/PR titles once you open the PR. Want me to commit on the branch?