Repository navigation
Conversation
#moduleCompletionPoint expanded every child of each visited node with `pending.push(...childNodes(node))`. A node's child count follows the source (array elements, call arguments, statements), so a loaded module factory that holds a very large array literal overflowed the call stack. The analysis worker then reported the RangeError as a memory resource_constraint, dropped the file's module and chunk graph, and advised retrying with more memory. Walk the factory body with the shared traverseJavaScriptAst, which owns child expansion and can skip nested functions and classes, and remove the now unused childNodes import. The earliest-return selection is unchanged. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01CRnrm8wZ6Q4MXQPQda6zvF
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0105d2d38d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| // The shared traversal owns child expansion. A node's child count follows | ||
| // the source (array elements, call arguments, statements), so it must never | ||
| // be spread into call arguments, which overflows the stack on large data. | ||
| traverseJavaScriptAst(factory.body, { |
There was a problem hiding this comment.
Record before/after resource measurements
For this million-child performance/resource fix, the validation supplied with the commit reports only failure/success and graph counts; it does not give elapsed time, CPU time, peak process-family memory, or cold/warm context for an equivalent completed workload (for example, the 200,000-element case that completes on both revisions). Without those measurements, the new traversal's per-node generator/frame overhead and the added capacity test have not been shown to remain within safe resource bounds, despite the repository explicitly requiring these comparisons for cost-affecting changes.
AGENTS.md reference: AGENTS.md:L52-L55
Useful? React with 👍 / 👎.
|
Preserve CommonJS literal paths and confined ESM URL semantics, including package main fallback, directory intent, Unicode identity, and present opaque modules. Parse extraction inputs at their AST/source owner, retain skipped HTML and source-map coverage, and distinguish endpoint candidates from proven receiver facts. Version structural fingerprints with computed literal contents and propagate them through worker contracts. Reviewed fixes include #1810, #1840, #2642, #2700, #2702, #2714, #2803, #2960, #2968, #2986, #3035, and #3036. Validation: 158 resolver tests passed; public CLI/MCP module lookup controls, package-main/Unicode workflows, and six builtin workflows passed in the current compiled lane. Worker schema/fingerprint regressions passed. Large public pdf.js completion and real Electron analysis remain unverified.
|
CI-fix track: this change is already on main. b58adaf lists #3035 among its reviewed fixes, and main's |
|
TL;DR: The fix works on Node 22, 24 and 26. Without it, Node 24.18.0 overflows the stack at about 261,000 elements, and with it files far past that size complete. Main already holds the same walk (b58adaf), so this may be superseded. I tested head 0105d2d as pushed. GitHub now says it conflicts with main eb44921. For "before", I reverted the one source file to the merge-base b9b3a90. Results
Threshold, before, Node 24.18.0: 260,937 elements pass. 261,718 fail with the stack error. Three runs at each size agreed. Head, Node 24.18.0: 1,000,000 elements pass. Between 1,437,500 and 1,468,750 the worker runs out of its default 1 GiB heap. That is a different limit. With Time and memory (the Codex question)Both builds complete the 200,000-element file. Four runs each, interleaved, medians:
Run-to-run spread is about the same size as the gap. Output at 200,000 elements is byte-identical between the builds. At 1,000,000 elements, head takes 18.2 s and before takes 5.9 s. Before stops early with a failure, so that is not like for like. Not run
Thanks, LeonBytes, for the fix and the generator. Another test job ran on this box. Load average (busy tasks over 1 minute, on 24 threads) was 0.9 to 2.3. Test setupCommandsEach run sat under 🤖 Generated with Claude Code (Sonnet 5.5, verified by Opus 5.5) 🦊 |
|
Heads up: main already has this change in b58adaf. The code is in 🤖 Generated with Claude Code (Sonnet 5.5, verified by Opus 5.5) 🦊 |
|
Thanks @LeonBytes. Closing this PR as superseded by b58adafa4 on Main uses a bounded iterative AST traversal instead of spreading source-sized children into call arguments, and includes the large-array stack-overflow regression. This is an unmerged closure: it does not label this PR as merged or remove contributor history/credit. The decision uses the current source diff and existing validation record; no new local test or provider run is claimed. |
Summary
Analysis fails for a whole file when a loaded module's factory contains a very large array literal.
#moduleCompletionPointdidpending.push(...childNodes(node)), and spreading a million children overflows the call stack. The worker reportsMaximum call stack size exceededas a memoryresource_constraintand suggests retrying with more memory, which doesn't help.This swaps the hand-written walk for the existing
traverseJavaScriptAst. No issue exists for this; I found it while reading the code.Problem and expected behavior
A
load()-ed module whose factory holds a huge array literal should be analyzed like any other module. Withrea analyze-javascript-application <dir> --json:--stack_size=2048).main.js):analysis_failure, coderesource_constraint, resourcememory, reasonmain.js: Maximum call stack size exceeded.The graph for
main.jsgoes from oneunknownnode plus the asset node (6 nodes overall) to 4 module nodes, 1 chunk node and the asset node (18 overall). I didn't measure the exact element count where it starts failing; it depends on stack size and host.Fixture generator
Change and scope
#moduleCompletionPointnow callstraverseJavaScriptAst(factory.body, { skip, enter }). The body root is still always entered, nested functions and classes are still skipped, and the earliestReturnStatementis still picked bystart. The unusedchildNodesimport is removed. SincechildNodesis documented as the single place that expands AST children, this removes a duplicate walker instead of adding a helper.I read the other
push(...)spreads insrc/domain/javascript(javascriptAstFingerprint.ts,javascriptSemanticObjectReferences.ts) and left them alone: their sizes come from one node's tokens or one class's fields, not from a source-sized child list. That is from reading, not testing.Not touched: the failure classification. A stack overflow shows up as a memory
resource_constraint, which is misleading, but that is your call.Contract and boundary impact
Semantic owner and earliest changed stage: symbolic bindings in
src/domain/javascript(Electron wrapped call paths).Contribution scope fit and linked maintainer decision: fix inside existing boundaries; not applicable.
CLI and MCP/tool-catalog contract: unchanged. For the affected input, a per-file failure becomes the normal graph.
Provider, bridge, target-format, or platform compatibility: none; static analysis only.
Evidence, artifact, provenance, or reconstruction contract: unchanged.
Target selection, authority, upstream behavior, and cleanup details: not applicable.
Generated metadata, package, or installation impact: none.
Read existing files or captured data.
Launch or attach to a process.
Inject instrumentation or run scripts/code.
Change process memory, registers, files, or configuration.
Contact network services.
Recover protected code or work around protections.
Documentation or usability only; no target interaction.
Not sure yet; investigation or maintainer guidance needed.
Evidence and regression coverage
Tests added or updated:
src/domain/javascript/javascriptSymbolicBindings.test.ts, "completes a loaded module at its earliest return past a very large array literal". It replaces the elements of a parsed array with 1,000,000 synthetic numeric literals (faster than parsing a 3.5 MB source) and checks the loaded namespace completes at the factory's earliest barereturn. The size matters: 200,000 elements didn't overflow in the test worker either.Base reproduction: with only the source change stashed, the file shows
27 tests | 1 failed(the new one); with the change all 27 pass.User-visible CLI/MCP output: see the numbers above.
Remaining proof gaps: no real-provider, Windows or macOS run; exact stack threshold not measured.
Observed, derived, and inferred claims remain distinguishable.
Artifact identity, source provenance, and failed attempts remain preserved.
Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.
Validation performed
Linux, Node v22.22.0 (
.nvmrcpins 24.18.0), npm 10.9.4 (packageManageris [email protected]),npm ci --ignore-scripts.npx tsc --noEmit: exit 0npx oxfmt --checkandnpx oxlinton the two changed files: format passes; no new lint warningsnpm run verify:module-boundaries: passnpx knip: exit 0npx vitest run --project domain --project services src/domain/javascript src/application/javascript: 69 files, 1558 tests passednpm run build:cachedandnode scripts/rea.mjs analyze-javascript-application <fixture> --jsonon the 1,000,000-element fixture: fails before the change, noanalysis_failureafter itNot run:
npm run check,npm run check:pr,npm run docs:check, the boundary, cli-boundary, mcp-boundary, acceptance and process projects, and the real-provider lanes.Compatibility, safety, and release
Before merge
type(scope): outcome.