Skip to content

Regression: High-frequency subscription (~10Hz) slow in rclnodejs 1.8.1 (worked in 0.21.4) #1394

@sumit00000

Description

@sumit00000

Description

  • Library Version: rclnodejs 1.8.1 (regression)
  • Previously working Version: rclnodejs 0.21.4
  • ROS Version: ROS2 Humble
  • Platform / OS: Ubuntu 22.04

Steps To Reproduce

import * as rclnodejs from 'rclnodejs';

let lastTs: number;
rclnodejs.init().then(() => {
  const node = new rclnodejs.Node('test_node');

  node.createSubscription(
    'std_msgs/msg/Float64MultiArray',
    '/map_to_base_link_pose2d',
    (msg: any) => {
      const now = Date.now();
      if (lastTs) {
        console.log('Raw Hz:', (1000 / (now - lastTs)).toFixed(2));
      }
      lastTs = now;
    }
  );

  rclnodejs.spin(node);
});

Expected Behavior
NodeJS subscription should receive messages at ~10Hz, matching the ROS2 topic publishing rate.

Actual Behavior
NodeJS subscription receives callbacks at ~1.5–1.8Hz.
Messages appear delayed or dropped, despite ROS2 publishing at 10Hz.
Regression compared to rclnodejs 0.21.4.
Workarounds like setImmediate() do not fix the problem.

Additional Notes / Observations
This issue only appears in rclnodejs 1.8.1.
High-frequency topics are significantly affected; lower-frequency topics (~1–2Hz) are unaffected.
Likely related to the NodeJS event loop integration or the subscription dispatch mechanism in the new version.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions