← Back to Pull requests

Add Timer.clock accessor #1599

Closed
unknown closed this pull request without merging on Sep 15, 2026 01:49 UTC
View on GitHub
unknown unknown commented on Sep 14, 2026 07:32 UTC
Author

Adds the rcl_timer_clock item of the parity checklist in #1330: a Timer.clock accessor, matching rclpy's Timer.clock.

Design

  • timer.clock returns the Clock the timer was created with: the clock passed to node.createTimer(), or the node's clock when none was passed. Node.createTimer() now hands that clock to the Timer constructor. No new native binding: the addon is unchanged.

  • Behaviour change: Because a Timer now keeps a reference to its Clock, Node.destroy() releases the timer handles explicitly. Timer handles are children of the clock handle rather than of the node handle, so until now they were finalized only once the clock was garbage collected; that also kept the thread-safe function of setOnResetCallback() alive.

  • types/timer.d.ts gets readonly clock: Clock and the tsd test covers it.
  • How tested

    mocha test/test-timer.js on ROS 2 Kilted (Node 22), with the new tests applied before the change:

      24 passing (2s)
      2 failing
    
      1) timer.clock returns the clock the timer was created with:
         AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:
         + undefined
         - ROSClock { _clockType: 1, _handle: RclHandle {} }
      2) timer.clock exposes ROS time of a ROSClock timer: (same assertion)
    

    After the change: 26 passing, 1 pending, and the process exits on its own. The new tests check the node clock, a custom STEADY_TIME clock passed as the 4th argument, a ROSClock passed as the 3rd argument with a ROS time override read back through timer.clock.now(), and that timer.clock is read-only. The full suite in the same container: 1454 passing, 14 pending; the 2 failures are HTTP-transport timeouts in test/test-web-http.js that fail identically on unmodified develop there. prettier, eslint and tsd are clean.

    Revision 2 (review): the getTimerClock native binding and the tests that compared its result with clock.handle were removed; the remaining tests are unchanged.

    Revision 3 (review): dropped the clock = null constructor default and added a CONTRIBUTORS.md entry; no functional change.

    Links

  • https://github.com/RobotWebTools/rclnodejs/issues/1330 (rcl_timer_clock under "Clock & Time")

  • rclpy Timer.clock: https://github.com/ros2/rclpy/blob/rolling/rclpy/rclpy/timer.py
  • This change was prepared with an AI agent operated by KR-Ravindra, who reviewed and tested it.

    Diff: 300 lines (+225 / -75) across 3 files Reviewer: KR-Ravindra Review duration: 1097m
    All Vouch review confidence checks passed
    Residual risk 0.16 = Change Risk (0.40) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.40 · 300 lines diff across 3 files
    0.40
    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.341
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #1599"
    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: 40.1% (MEDIUM) · Higher = larger blast radius
    40.1%
    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: 15.8% · Safe to merge
    15.8%