influxdata / influxdata/influxdb-client-js
this.dateToProtocolTimestamp is not a function
- Dominant language
- TypeScript
- Stars
- 352
- Forks
- 69
- Avg merge
- 10m
- Merged PRs (30d)
- 11
Description
### Specifications
* Client Version: 1.35.0
* InfluxDB Version: 2.7.11
* Platform: MacOs
### Code sample to reproduce problem
```javascript
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_
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the JavaScript reproduction and the convertTime/toLineProtocol stack entries in dist/index.mjs, then compare the timestamp usage with the client example referenced in the issue. Determine why a Date value reaches dateToProtocolTimestamp incorrectly; done means the reported Date input is handled without the TypeError and the behavior is covered by a regression test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- backend, databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100