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

Invalid string length exception on large reads #106

Closed
genzgd opened this issue Oct 1, 2022 · 1 comment
Closed

Invalid string length exception on large reads #106

genzgd opened this issue Oct 1, 2022 · 1 comment

Comments

@genzgd
Copy link

genzgd commented Oct 1, 2022

Crashes when reading 50,000,000 numbers (at least on my Mac M1).

Code to reproduce (against localhost/local docker):

const { createClient } = require('@clickhouse/client')

(async () => {
    const client = createClient();
    console.log(Date.now() / 1000)
    const result = await client.query({
        query: 'SELECT number FROM numbers(50000000)',
        format: "JSONCompactEachRow"
    });
    console.log(Date.now() / 1000);
    const stuff = await result.json();
    console.log(stuff.length);
    console.log(Date.now() / 1000);

})()

Exception:

1664586660.882
1664586660.895
AbortError: The operation was aborted
    at Object.destroyer (node:internal/streams/destroy:305:11)
    at createAsyncIterator (node:internal/streams/readable:1141:19)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  code: 'ABORT_ERR'
}
/Users/geoff/projects/nodetests/node_modules/@clickhouse/client/dist/utils/stream.js:16
        result += textDecoder.decode(chunk, { stream: true });
                              ^

RangeError: Invalid string length
    at getAsText (/Users/geoff/projects/nodetests/node_modules/@clickhouse/client/dist/utils/stream.js:16:31)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Rows.text (/Users/geoff/projects/nodetests/node_modules/@clickhouse/client/dist/rows.js:37:17)
    at async Rows.json (/Users/geoff/projects/nodetests/node_modules/@clickhouse/client/dist/rows.js:50:45)
    at async /Users/geoff/projects/nodetests/index.js:47:19

Node.js v18.9.0
@slvrtrn
Copy link
Contributor

slvrtrn commented Oct 2, 2022

Unfortunately, that seems to be a hard Node.js limitation. We cannot use strings larger than 512Mb at the moment. If I understand it correctly, the max size was increased from 256Mb to 1Gb in the past and then reduced to 512Mb.

See

My tests showed that it indeed crashes at around 512Mb of size, with the resulting string's length around 536870888.

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

2 participants