Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RangeError: Invalid string length on a big dataset #599

Open
metalgrid opened this issue Sep 27, 2021 · 0 comments
Open

RangeError: Invalid string length on a big dataset #599

metalgrid opened this issue Sep 27, 2021 · 0 comments

Comments

@metalgrid
Copy link

Expected Behavior

Promise resolves successfully and invokes the callback passed to .then()

Actual Behavior

Uncaught exception thrown and callback never executed:

node_modules/influx/lib/src/pool.js:154
                    output += str.toString();
                                  ^

RangeError: Invalid string length

Steps/Code to Reproduce the Problem

  1. Run the following against a database with millions of records.
const Influx = require('influx');

const influx = new Influx.InfluxDB({
    host: '127.0.0.1',
    database: 'bigdb',
    username: 'influxuser',
    password: '*****',
    schema: [{
        'measurement': 'stats',
        fields: {
            children: Influx.FieldType.INTEGER
        },
        tags: [ 'host', 'reg', 'vl' ]
    }]
});

const dateFrom = new Date();
dateFrom.setUTCHours(0, 0, 0, 0);
dateFrom.setUTCDate(dateFrom.getUTCDate()-1);
const dateTo = new Date(dateFrom);
dateTo.setUTCHours(23, 59, 59, 0);

influx.query(`SELECT * FROM "stats" WHERE time > '${dateFrom.toISOString()}' AND time < '${dateTo.toISOString()}'`).then( (results) => {
    const output = fs.createWriteStream('test.csv.gz');
    const compressor = zlib.createGzip();
    compressor.pipe(output);
    results.forEach( (row) => {
        compressor.write(`stats,"host=${row.host},reg=${row.reg},vl=${row.vl}",${row.time.toISOString()},${row.children},${row.reg},${row.host}\n`);
    });
    compressor.end();
});
// ...

Specifications

  • Version: node-influx v5.9.2, nodejs v14.17.6, npm v6.14.15
  • Platform: Linux (CentOS 7), InfluxDB v1.7.6 (git: 1.7 01c8dd416270f424ab0c40f9291e269ac6921964)
  • Subsystem:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant