Repository navigation
Description
Before submitting
- I searched the open and closed issues for a related report. Closest: [Bug] analyze_javascript_application fails result validation when any module imports itself #1129 (self-referential import edges, fixed by fix(javascript): omit self-referential import edges with disclosure #1130). This is the same invariant reached through a different composer that fix(javascript): omit self-referential import edges with disclosure #1130 did not change. Also seen: analyze-javascript-application: zero output for minutes then generic unreadable_output failure on a 24 MB Electron ASAR (Obsidian 1.12.7) #746, analyze-javascript-application: unreadable_output '/label (too_small)' on a Vite bundle containing SheetJS (xlsx) #861, analyze-javascript-application: schema rejection at /identity/key (too_small) on plain minified JS directory #1009 (different
unreadable_outputcauses). - I removed credentials, tokens, private paths, and sensitive target data.
Area
Evidence, artifacts, or reconstruction
Observed behavior
analyze-javascript-application on a directory of production webpack 5 chunks fails after a complete analysis:
Result schema rejected 8 issues at /edges/2092 (custom)
Running the reconstruction in-process and validating with the package's own javascriptApplicationGraphSchema shows all 8 issues are the invariant Application graph edges cannot be self-referential. Every rejected edge is an imports edge with properties.kind: "bundler-async-chunk", resolution_status: "resolved", whose source and target are the same javascript-chunk node:
- 3 edges come from single-id chunk files whose code requests their own id (
__webpack_require__.e(<own id>)). - 5 edges come from merged chunk files that push several ids at once (e.g.
push([[a,b,c,…], {...}])), where code inside requests one of the file's own ids.
The graph had 52,207 nodes and 86,102 edges; 8 self-referential edges were enough to lose the entire result.
Reproduction
- Create a directory containing one file,
1.js:"use strict";(self.webpackChunkdemo=self.webpackChunkdemo||[]).push([[1],{10(e,t,r){r.e(1).then(r.bind(r,11))},11(e,t,r){r.r(t)}}]);
- Run
npx rea-agents@6.0.0 analyze-javascript-application <dir> --json. - Observe
unreadable_outputwithResult schema rejected 1 issue at /edges/4 (custom).
Control: replace r.e(1) with r.e(2) and add 2.js containing (self.webpackChunkdemo=self.webpackChunkdemo||[]).push([[2],{20(e,t,r){r.r(t)}}]);. The analysis succeeds with one bundler-async-chunk edge.
Expected behavior
Same treatment #1130 gave self-imports: a chunk requesting its own id carries no chunk-graph information, so the composer should omit that edge, count it, and disclose the omission in the graph limitations, letting the rest of the analysis survive.
Impact and scope
Any webpack/Rspack output where a chunk file requests one of its own chunk ids cannot be analyzed at all. This shape appears in real production bundles: 8 times in a 367-file capture of a large commercial web app. It also reaches web captures, since export_web_scripts hands its analysis_input straight to this operation. Evidence integrity is unaffected (nothing partial is emitted); the cost is total loss of the result.
REA version
rea-agents 6.0.0 (npm latest on 2026-10-09). The composer below is unchanged on main at 441813c070; the file was last changed in f0a68dce60.
Runtime and platform
Node.js 24.18.0; Windows 11 Pro 10.0.26200 x64
Target and artifact context
Directory produced by inspect-web-page --include-script-sources + export-web-scripts: 367 webpack 5 chunk files (~16 MB, one webpackChunk* runtime, no source maps). The one-file reproduction above shows the same failure without the original target.
Interface
CLI
Earliest failure stage
Artifact or evidence registration
Relevant output or evidence
$ rea analyze-javascript-application <dir> --json
{
"error": "JavaScript application analysis failed",
"code": "unreadable_output",
"category": "execution_failure",
"message": "Analysis returned an unreadable result. Retry once; if it continues, run `rea doctor`.",
"retryable": false,
"details": {
"operation": "analyze_javascript_application",
"reason": "Result schema rejected 8 issues at /edges/2092 (custom)"
}
}
All 8 issues (from javascriptApplicationGraphSchema.safeParse on the reconstructed graph):
custom at /edges/{2092,14091,31317,33578,37517,58602,72776,74339}:
"Application graph edges cannot be self-referential"
Each edge: relation "imports", properties.kind "bundler-async-chunk",
bundler "webpack", resolution_status "resolved", source node == target node (javascript-chunk).
The failure is deterministic: three runs gave the same result. The remediation's "retry once / run rea doctor" cannot help here.
Typed outcome or recovery expected
A successful result whose graph.limitations discloses something like "N bundler async-chunk references resolved back to the requesting chunk itself and were omitted; application graph edges cannot be self-referential."
Analysis or suspected cause
Source-derived, not tested against a patched build. addBundlerRuntimeEdges in src/application/javascript/JavaScriptArtifactGraphBundlers.ts iterates registration.async_chunk_keys, resolves each through context.chunkNodes, and calls context.accumulator.addEdge with source_node_id: chunk.node_id unconditionally. When the key is one of the file's own registered ids, resolved.node_id === chunk.node_id. #1130 added the skip-and-disclose step only to addImportRelationship in JavaScriptModuleRelationships.ts and threaded selfImports into graphLimitations; the bundler path was not covered. A fix could skip resolved?.node_id === chunk.node_id in that loop and report the count alongside relationshipOmissions. A boundary test could mirror tests/boundary/cli/javascriptSelfImportRelationships.test.ts with the one-file fixture above, plus a merged multi-id chunk case.
Additional context
Separately observed: on this failure the CLI exits with status 0 and the --full-output envelope reports "ok": true around the error object. If that is not the intended contract for analysis failures, it may deserve its own issue.
Activity
fix(javascript): omit self-referential static references with disclos…
fix(javascript): omit self-referential static references with disclos…
fix(javascript): omit self-referential bundler edges with disclosure