ClickHouse/clickhouse-js

Uncatchable parse errors when incoming data is not a valid JSON

ayZagen opened this issue · 0 comments

Wrapping the client.query method does not catch this error. This error is caught with unhandledRejection listener on process.

Here is the exception

Node.js v22.3.0
undefined:1
024-09-09 19:30:37.979","level":"info","event_type":"getStats"}
 ^

SyntaxError: Unexpected number in JSON at position 1 (line 1 column 2)
    at JSON.parse (<anonymous>)
    at Object.json (/usr/src/app/node_modules/.pnpm/@clickhouse+client@1.5.0/node_modules/@clickhouse/client/dist/result_set.js:134:41)
    at Transform.<anonymous> (/usr/src/app/node_modules/.pnpm/@clickhouse+client@1.5.0/node_modules/@clickhouse/client/dist/result_set.js:88:41)
    at Transform.emit (node:events:520:28)
    at Transform.emit (node:domain:488:12)
    at addChunk (node:internal/streams/readable:559:12)
    at readableAddChunkPushObjectMode (node:internal/streams/readable:536:3)
    at Readable.push (node:internal/streams/readable:391:5)
    at Transform.transform [as _transform] (/usr/src/app/node_modules/.pnpm/@clickhouse+client@1.5.0/node_modules/@clickhouse/client/dist/result_set.js:154:34)
    at Transform._write (node:internal/streams/transform:171:8)