[GH-ISSUE #4474] [Bug] WASM glue still uses unnamed TypeScript parser for valid JavaScript #1773

Closed
opened 2026-10-16 21:10:06 +00:00 by bsakaguchi · 1 comment
Owner

Originally created by @dayvison2b on GitHub (Oct 16, 2026).
Original GitHub issue: https://github.com/morluto/rea/issues/4474

Before submitting

  • I searched open and closed issues and PRs for related reports.
  • I removed credentials, private paths and sensitive target data.

Area

Evidence, artifacts, or reconstruction

Observed behavior

Follow-up to #3780: the WASM glue consumer still parses selected .js sources without their filenames. A valid conditional-arrow expression makes the entire glue file fail parsing, losing a subsequent ordinary .wasm reference.

With the published rea-agents@6.5.0 package and real WABT 1.0.42, inspect-wasm-artifact exits zero and validates the WASM module, but reports the glue as parse_status: "failed" with references: []. Removing only the conditional-arrow statement restores the reference.

Reproduction

Use an eight-byte empty WASM module, hex 0061736d01000000, as module.wasm. Place these two JavaScript files beside it:

// glue-failure.js
const pick=n===0?H=>({start:H.startY}):H=>({start:H.startX});
fetch("./module.wasm");
// glue-control.js
fetch("./module.wasm");

Configure REA_WABT_BIN_DIRECTORY to an absolute directory containing the real WABT 1.0.42 tools. The executed CLI commands were equivalent to the following, with absolute package and fixture paths substituted:

node <rea-package>/scripts/rea.mjs inspect-wasm-artifact <fixtures>/module.wasm --glue_paths <fixtures>/glue-failure.js --format json
node <rea-package>/scripts/rea.mjs inspect-wasm-artifact <fixtures>/module.wasm --glue_paths <fixtures>/glue-control.js --format json

Each public CLI command was executed once. Both exited zero with empty stderr and validation: "valid"; both reported a module digest matching the selected bytes. No WASM module or JavaScript fixture was executed. Node's vm.Script separately compiled the failing JavaScript fixture successfully without running it.

Expected behavior

Both files should parse as JavaScript. The failing fixture should retain the ./module.wasm literal at line 2, column 6, associated with the selected sibling module. The conditional expression should not prevent analysis of the remainder of the file.

Impact and scope

All static WASM references in the affected selected glue file are unavailable, with an explicit failed parse status. This is demonstrated with the reduced fixture; prevalence in real applications and other host platforms is unmeasured.

The public CLI was exercised with the released package. The same failure was independently reproduced by executing the original adapter/parser modules from current upstream main, pinned below. That current-source reproduction strips TypeScript annotations and rewrites import locations in memory; it does not change production functions or arguments. A current-main compiled CLI and the public MCP interface were not independently exercised.

REA version

Public CLI: rea-agents@6.5.0 (--version verified).

Current-source adapter reproduction: fe2a398dd9ab290ba6cb3411403d319cec8d07a2.

Runtime and platform

Windows x64, Node.js v24.17.0, @babel/parser 8.0.4 and @babel/types 8.0.4 for the current-source reproduction; real WABT 1.0.42 for the CLI reproduction. The official portable WABT release archive matched its published SHA-256.

Target and artifact context

Source-owned two-line JavaScript fixture and an eight-byte valid empty WebAssembly core module. No third-party application is needed.

Interface

CLI

Earliest failure stage

Native analysis or reconstruction — specifically inert JavaScript glue parsing before literal collection.

Relevant output or evidence

Relevant fields from the public CLI's normalized_result:

{
  "validation": "valid",
  "glue": [{ "parse_status": "failed", "references": [] }]
}

The control returns parse_status: "complete" and one reference with value ./module.wasm, line 1, column 6, association: "local-path-candidate" and evidence_kind: "static-literal". Its candidate_paths includes the selected module.

For the complete failing text, parseJavaScriptSource(source, "glue.js") returns an AST with zero errors; parseJavaScriptSource(source) returns null. The unchanged associateWasmGlue returns failed/zero references on both the local checkout and the pinned current upstream source.

Analysis or suspected cause

Source-derived and supported by the reduced reproduction: WasmGlueAdapter.ts calls parseJavaScriptSource without path, although the selected filename is already an adapter argument. The parser's filename policy keeps TypeScript enabled for unnamed sources. TypeScript interprets this conditional-arrow shape differently.

Additional context

Related-report check on 2026-10-16:

  • #3780 / merged #3782 fixed the general filename-aware parser while deliberately preserving the unnamed-source fallback. The WASM consumer does not pass the filename, so this is a remaining affected flow of that known problem.
  • Closed #2954 concerns the analogous missing filename in browser source-map extraction, a separate consumer.
  • Open #4001 / #4149 concern directive literals omitted after a successful parse. This fixture fails before traversal, and its .wasm literal is a call argument.
  • Open #3402 / #3455 concern candidate-path equivalence after parsing succeeds.

No existing issue or pending correction covering this specific WASM parser-mode failure was found. No implementation fix is included with this report.

Originally created by @dayvison2b on GitHub (Oct 16, 2026). Original GitHub issue: https://github.com/morluto/rea/issues/4474 ### Before submitting - [x] I searched open and closed issues and PRs for related reports. - [x] I removed credentials, private paths and sensitive target data. ### Area Evidence, artifacts, or reconstruction ### Observed behavior Follow-up to #3780: the WASM glue consumer still parses selected `.js` sources without their filenames. A valid conditional-arrow expression makes the entire glue file fail parsing, losing a subsequent ordinary `.wasm` reference. With the published `rea-agents@6.5.0` package and real WABT 1.0.42, `inspect-wasm-artifact` exits zero and validates the WASM module, but reports the glue as `parse_status: "failed"` with `references: []`. Removing only the conditional-arrow statement restores the reference. ### Reproduction Use an eight-byte empty WASM module, hex `0061736d01000000`, as `module.wasm`. Place these two JavaScript files beside it: ```js // glue-failure.js const pick=n===0?H=>({start:H.startY}):H=>({start:H.startX}); fetch("./module.wasm"); ``` ```js // glue-control.js fetch("./module.wasm"); ``` Configure `REA_WABT_BIN_DIRECTORY` to an absolute directory containing the real WABT 1.0.42 tools. The executed CLI commands were equivalent to the following, with absolute package and fixture paths substituted: ```text node <rea-package>/scripts/rea.mjs inspect-wasm-artifact <fixtures>/module.wasm --glue_paths <fixtures>/glue-failure.js --format json node <rea-package>/scripts/rea.mjs inspect-wasm-artifact <fixtures>/module.wasm --glue_paths <fixtures>/glue-control.js --format json ``` Each public CLI command was executed once. Both exited zero with empty stderr and `validation: "valid"`; both reported a module digest matching the selected bytes. No WASM module or JavaScript fixture was executed. Node's `vm.Script` separately compiled the failing JavaScript fixture successfully without running it. ### Expected behavior Both files should parse as JavaScript. The failing fixture should retain the `./module.wasm` literal at line 2, column 6, associated with the selected sibling module. The conditional expression should not prevent analysis of the remainder of the file. ### Impact and scope All static WASM references in the affected selected glue file are unavailable, with an explicit failed parse status. This is demonstrated with the reduced fixture; prevalence in real applications and other host platforms is unmeasured. The public CLI was exercised with the released package. The same failure was independently reproduced by executing the original adapter/parser modules from current upstream main, pinned below. That current-source reproduction strips TypeScript annotations and rewrites import locations in memory; it does not change production functions or arguments. A current-main compiled CLI and the public MCP interface were not independently exercised. ### REA version Public CLI: `rea-agents@6.5.0` (`--version` verified). Current-source adapter reproduction: `fe2a398dd9ab290ba6cb3411403d319cec8d07a2`. ### Runtime and platform Windows x64, Node.js v24.17.0, @babel/parser 8.0.4 and @babel/types 8.0.4 for the current-source reproduction; real WABT 1.0.42 for the CLI reproduction. The official portable WABT release archive matched its published SHA-256. ### Target and artifact context Source-owned two-line JavaScript fixture and an eight-byte valid empty WebAssembly core module. No third-party application is needed. ### Interface CLI ### Earliest failure stage Native analysis or reconstruction — specifically inert JavaScript glue parsing before literal collection. ### Relevant output or evidence Relevant fields from the public CLI's `normalized_result`: ```json { "validation": "valid", "glue": [{ "parse_status": "failed", "references": [] }] } ``` The control returns `parse_status: "complete"` and one reference with value `./module.wasm`, line 1, column 6, `association: "local-path-candidate"` and `evidence_kind: "static-literal"`. Its `candidate_paths` includes the selected module. For the complete failing text, `parseJavaScriptSource(source, "glue.js")` returns an AST with zero errors; `parseJavaScriptSource(source)` returns `null`. The unchanged `associateWasmGlue` returns failed/zero references on both the local checkout and the pinned current upstream source. ### Analysis or suspected cause Source-derived and supported by the reduced reproduction: [WasmGlueAdapter.ts](https://github.com/morluto/rea/blob/fe2a398dd9ab290ba6cb3411403d319cec8d07a2/src/wasm/WasmGlueAdapter.ts#L14) calls `parseJavaScriptSource` without `path`, although the selected filename is already an adapter argument. [The parser's filename policy](https://github.com/morluto/rea/blob/fe2a398dd9ab290ba6cb3411403d319cec8d07a2/src/domain/javascript/javascriptSourceParser.ts#L24) keeps TypeScript enabled for unnamed sources. TypeScript interprets this conditional-arrow shape differently. ### Additional context Related-report check on 2026-10-16: - #3780 / merged #3782 fixed the general filename-aware parser while deliberately preserving the unnamed-source fallback. The WASM consumer does not pass the filename, so this is a remaining affected flow of that known problem. - Closed #2954 concerns the analogous missing filename in browser source-map extraction, a separate consumer. - Open #4001 / #4149 concern directive literals omitted after a successful parse. This fixture fails before traversal, and its `.wasm` literal is a call argument. - Open #3402 / #3455 concern candidate-path equivalence after parsing succeeds. No existing issue or pending correction covering this specific WASM parser-mode failure was found. No implementation fix is included with this report.
Author
Owner

@matbrgz commented on GitHub (Oct 16, 2026):

Cross-referencing with sibling WASM glue parser issue #4001 ([Bug] WASM glue inspection omits string literals in JavaScript directive prologues). Both reports target the JavaScript glue parser within inspect_wasm_artifact where valid JS constructs are misparsed or processed by an inappropriate parser mode.

Consolidated under Cluster T (WASM Glue JavaScript Inspection & Parsing) in tracker #4330.

<!-- gh-comment-id:6219883000 --> @matbrgz commented on GitHub (Oct 16, 2026): Cross-referencing with sibling WASM glue parser issue #4001 (`[Bug] WASM glue inspection omits string literals in JavaScript directive prologues`). Both reports target the JavaScript glue parser within `inspect_wasm_artifact` where valid JS constructs are misparsed or processed by an inappropriate parser mode. Consolidated under **Cluster T (WASM Glue JavaScript Inspection & Parsing)** in tracker #4330.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#1773
No description provided.