← Back to Pull requests

module: fix --check on ambiguous ESM files #65203

Closed
unknown closed this pull request without merging on Aug 12, 2026 21:47 UTC
View on GitHub
unknown unknown commented on Aug 10, 2026 21:15 UTC
Author

Fixes #65202. node --check exits 0 on a .js file that contains module syntax and a genuine syntax error, when the file's format is ambiguous (no "type" in the nearest package.json).

Such a file has no format of its own, and defaultGetFormat() reports it as null. checkSyntax() passed that null straight to wrapSafe(), which parses as CommonJS; the module syntax makes that parse bail out before the rest of the file is parsed, so nothing was reported.

At load time the goal for an ambiguous file is decided by looking for module syntax in the source, so this decides it the same way before choosing how to parse.

$ node --check broken.js ; echo "exit: $?"    # import + `var = ;`
exit: 0                                        # before
...
SyntaxError: Unexpected token '='              # after
exit: 1

Verified against a local build. Files whose format is known are unaffected, and ambiguous files without module syntax still parse as CommonJS, so sloppy-mode sources keep working:

| case | before | after |
| --- | --- | --- |
| .js ambiguous + module syntax + error | exit 0 | exit 1 |
| .js ambiguous, sloppy-mode with | exit 0 | exit 0 |
| .js ambiguous, plain syntax error | exit 1 | exit 1 |
| .mjs, or "type" set | exit 1 | exit 1 |
| .js ambiguous, valid ESM | exit 0 | exit 0 |

The added fixture fails the existing test-cli-syntax-bad assertions before this change and passes after. All test-cli-syntax* suites pass locally.

Fixes: https://github.com/nodejs/node/issues/65202

Diff: 193 lines (+144 / -49) across 2 files Reviewer: daltino Review duration: 2912m
All Vouch review confidence checks passed
Residual risk 0.14 = Change Risk (0.36) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.36 · 193 lines diff across 2 files
0.36
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
0.17
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
60%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size diff_size
0.315
Shallow Review Depth shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #65203"
general weight: 0.35
Reviewers
Assignees
Unassigned
Labels
risk: low confidence: 60.5% reviewed
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 36.0% (MEDIUM) · Higher = larger blast radius
36.0%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 60.5% · Lower = rushed or shallow review
60.5%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 14.2% · Safe to merge
14.2%
Repository