Skip to content

this.dateToProtocolTimestamp is not a function #1132

@davodm

Description

@davodm

Specifications

  • Client Version: 1.35.0
  • InfluxDB Version: 2.7.11
  • Platform: MacOs

Code sample to reproduce problem

function _createBasePoint(options = {}) {
    const {
      operation,
      requestId,
      status,
      tokenId,
      userId,
      endpoint = 'unknown',
      timestamp = new Date(),
    } = options;

    const point = new Point(MEASUREMENT_NAME)
      .tag('operation', operation)
      .tag('status', status)
      .tag('request_id', requestId)
      .tag('endpoint', endpoint)
      timestamp


    if (tokenId) point.tag('token_id', tokenId);
    if (userId) point.tag('user_id', userId);

    return point;
  }

let point =_createBasePoint({
        operation: 'start',
        requestId,
        status: 'pending',
        tokenId,
        userId,
        endpoint: metadata?.endpoint || 'unknown',
        timestamp: new Date(),
      });
      // Add specific fields to this "start" operation
      point.floatField('estimated_amount', estimatedAmount);
      point.floatField('balance_before', tokenDoc.balance || 0);
})

Expected behavior

I expected to parse the Date() as it should.

Actual behavior

I'm using the nodejs client to interact with influxdb, but in sending timestamp as new Date (it's exactly like the example file) it throws this error:

TypeError: this.dateToProtocolTimestamp is not a function
at E.convertTime (./node_modules/@influxdata/influxdb-client/dist/index.mjs:5:1242)
at Fe.toLineProtocol (./node_modules/@influxdata/influxdb-client/dist/index.mjs:4:3994)
at E.writePoint (./node_modules/@influxdata/influxdb-client/dist/index.mjs:5:481)

Additional info

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions