InfluxCommunity / influxdb3-js

The JavaScript Client that provides a simple and convenient way to interact with InfluxDB 3.
https://influxcommunity.github.io/influxdb3-js/
MIT License
13 stars 4 forks source link

RpcError: Received RST_STREAM with code 0 #268

Closed johanhaest closed 8 months ago

johanhaest commented 8 months ago

Specifications

Code sample to reproduce problem

import { InfluxDBClient, Point } from '@influxdata/influxdb3-client'

async function main() {
    const client = new InfluxDBClient({
        host:'https://westeurope-1.azure.cloud2.influxdata.com', 
        token: 'XXXXX',
    })

    let database = `test-measurements`

    const points =
        [
            Point.measurement("census")
                .setTag("location", "Klamath")
                .setIntegerField("bees", 23),
            Point.measurement("census")
                .setTag("location", "Portland")
                .setIntegerField("ants", 30),
            Point.measurement("census")
                .setTag("location", "Klamath")
                .setIntegerField("bees", 28),
            Point.measurement("census")
                .setTag("location", "Portland")
                .setIntegerField("ants", 32),
            Point.measurement("census")
                .setTag("location", "Klamath")
                .setIntegerField("bees", 29),
            Point.measurement("census")
                .setTag("location", "Portland")
                .setIntegerField("ants", 40)
        ];

    for (let i = 0; i < points.length; i++) {
        const point = points[i];
        await client.write(point, database)
            // separate points by 1 second
            .then(() => new Promise(resolve => setTimeout(resolve, 1000)));
    }

    const query = `SELECT * FROM 'census' 
    WHERE time >= now() - interval '24 hours' AND 
    ('bees' IS NOT NULL OR 'ants' IS NOT NULL) order by time asc`

    const rows = await client.query(query, 'test-measurements')
    console.log(`${"ants".padEnd(5)}${"bees".padEnd(5)}${"location".padEnd(10)}${"time".padEnd(15)}`);
    for await (const row of rows) {
        let ants = row.ants || '';
        let bees = row.bees || '';
        let time = new Date(row.time);
        console.log(`${ants.toString().padEnd(5)}${bees.toString().padEnd(5)}${row.location.padEnd(10)}${time.toString().padEnd(15)}`);
    }

    client.close()
}

main()

Expected behavior

And output like the following:

ants bees location  time           
     23   Klamath   Fri Jul 21 2023 7:23:02 +00:00
30        Portland  Fri Jul 21 2023 7:23:04 +00:00
     28   Klamath   Fri Jul 21 2023 7:23:05 +00:00
32        Portland  Fri Jul 21 2023 7:23:06 +00:00
     29   Klamath   Fri Jul 21 2023 7:23:07 +00:00
40        Portland  Fri Jul 21 2023 7:23:08 +00:00

Actual behavior

RpcError: Received RST_STREAM with code 0
    at ClientReadableStreamImpl.<anonymous> (/Users/johanhaest/Projects/panenco/nestborn/influx_poc/node_modules/.pnpm/@protobuf-ts+grpc-transport@2.9.3_@grpc+grpc-js@1.10.1/node_modules/@protobuf-ts/grpc-transport/build/commonjs/grpc-transport.js:85:52)
    at ClientReadableStreamImpl.emit (node:events:518:28)
    at Object.onReceiveStatus (/Users/johanhaest/Projects/panenco/nestborn/influx_poc/node_modules/.pnpm/@grpc+grpc-js@1.10.1/node_modules/@grpc/grpc-js/build/src/client.js:357:28)
    at Object.onReceiveStatus (/Users/johanhaest/Projects/panenco/nestborn/influx_poc/node_modules/.pnpm/@grpc+grpc-js@1.10.1/node_modules/@grpc/grpc-js/build/src/client-interceptors.js:323:181)
    at /Users/johanhaest/Projects/panenco/nestborn/influx_poc/node_modules/.pnpm/@grpc+grpc-js@1.10.1/node_modules/@grpc/grpc-js/build/src/resolving-call.js:99:78
    at process.processTicksAndRejections (node:internal/process/task_queues:77:11) {
  code: 'INTERNAL',
  meta: {},
  methodName: 'DoGet',
  serviceName: 'arrow.flight.protocol.FlightService'

Additional info

No response

johanhaest commented 8 months ago

Looked like the storage engine being v2 was the issue. It's a bit weird that the tutorial from within the UI tells you to use this client + the error could actually be caught if the server engine is totally wrong. But anyway my issue is fixed.