Skip to content

Time#get secondsAndNanoseconds bug #531

@wayneparrott

Description

@wayneparrott

I've isolated an issue in Time where _nanoseconds is being modified when calling the getter 'secondsAndNanoseconds' in version 0.10.2 on MacOS Catalina.

This example program prints out the _nanoseconds before and after calling secondsAndNanoseconds. I can see _nanoseconds change after calling secondsAndNanoseconds. If I comment out the call to secondsAndNanoseconds, _nanoseconds remains unchanged. Notice in the example output how time2 values of _nanosecond are a subset of the original time1 value.

example output
time1 1572996022175992874
time2 572996022
time1 1572996022925996911
time2 572996022
time1 1572996023677128755
time2 572996023
time1 1572996024427889376
time2 572996024
time1 1572996025178983458
time2 572996025
time1 1572996025932756150
time2 572996025

const rcl = require('rclnodejs');

rcl.init().then(() => {
  const node = rcl.createNode('timer_ghost_node');
  const clock = new rcl.Clock();

  setInterval(() => {
    const now = clock.now();
    console.log('time1', now._nanoseconds);
    
    // the following getter is goofing up the _nanoseconds value of variable "now"
    // comment out this next line and _nanoseconds remains constant
    now.secondsAndNanoseconds;
    
    console.log('time2', now._nanoseconds);
  
  }, 750);

  rcl.spin(node);
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions