← Back to Pull requests

Write generated/generator.json only after message generation completes #1595

Closed
unknown closed this pull request without merging on Sep 09, 2026 04:50 UTC
View on GitHub
unknown unknown commented on Sep 08, 2026 21:36 UTC
Author

Problem

If message generation does not run to completion, rclnodejs.init() keeps treating the partial generated/ tree as complete. Every interface that was never written then fails with MESSAGE_NOT_FOUND on every start, and the only way out is to delete generated/ by hand. The two realistic ways to get there are the generating process being killed part-way (SIGKILL/OOM during npm install, Ctrl-C on generate-ros-messages, CI/container teardown) and any single package failing to generate (EACCES, ENOSPC, a malformed interface). In the second case npm install also exits 0, because the postinstall script only logs the error, so the partial tree is left behind silently.

Root cause

  • rosidl_gen/index.cjs:87-90 copies generator.json (the version marker init() uses to decide whether regeneration is needed) into generated/ before the per-prefix generateInPath() loop at rosidl_gen/index.cjs:103-105 has generated a single interface file.

  • index.js:422-424 (getCurrentGeneratorVersion() / forced) only regenerates when that file is absent or carries an older version, so a partial tree with a current-version marker is never regenerated.

  • scripts/generate_messages.cjs:36-38 catches the error, prints Caught error: ... and returns normally, so the process exits 0.
  • Fix

  • rosidl_gen/index.cjs: write generated/generator.json last, after the generateInPath() loop. generated/ is now created with fse.mkdirs() up front (the generator.json copy used to create it implicitly). A tree left behind by an interrupted or failed run has no marker, getCurrentGeneratorVersion() returns null, and init() regenerates it on the next start with no other change.

  • scripts/generate_messages.cjs: process.exit(1) in the catch handler so npm install and npx generate-ros-messages report the failure instead of succeeding with a partial tree.

  • test/test-messsage-generation-overlay.js: regression test that points AMENT_PREFIX_PATH at a prefix whose ament index lists a .msg file that does not exist, runs generateAll(true), and asserts that it fails and that no generated/generator.json was written.
  • How tested

    New test against the unmodified generator:

      override interface in overlay tests
        1) failed generation leaves no generator.json marker
      0 passing (100ms)
      1 failing
      1) override interface in overlay tests
           failed generation leaves no generator.json marker:
          AssertionError [ERR_ASSERTION]: Expected no generator.json after a failed generation
          + expected - actual
          -false
          +true
    

    With the fix:

      override interface in overlay tests
        ✔ failed generation leaves no generator.json marker (148ms)
      1 passing (156ms)
    

    Also checked that a successful generateAll(false) followed by generateAll(true) still produces generated/generator.json, generated/package.json and generated/srv_msg/, and that node scripts/generate_messages.cjs now exits 1 when a package fails to generate (generated/ is left without generator.json). npx prettier --check and npx eslint pass on the changed files.

    Links

  • https://github.com/RobotWebTools/rclnodejs/issues/1594

  • Earlier reports of users stuck in this state: https://github.com/RobotWebTools/rclnodejs/issues/546, https://github.com/RobotWebTools/rclnodejs/issues/688, https://github.com/RobotWebTools/rclnodejs/issues/1254
  • This change was prepared with an AI agent operated by KR-Ravindra, who reviewed and tested it.

    Diff: 440 lines (+330 / -110) across 5 files Reviewer: KR-Ravindra Review duration: 433m
    All Vouch review confidence checks passed
    Residual risk 0.18 = Change Risk (0.45) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.45 · 440 lines diff across 5 files
    0.45
    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.364
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #1595"
    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: 45.3% (MEDIUM) · Higher = larger blast radius
    45.3%
    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: 17.9% · Safe to merge
    17.9%