ClickHouse/clickhouse-js

Zlib decompression errors are not caught in case of failure responses

Closed this issue · 0 comments

Describe the bug

When response decompression is enabled malformed clickhouse failure responses will throw an unhandled promise rejection which cannot be caught on the application side by wrapping the query function in error handling logic.

Steps to reproduce

  1. Enable response decompression
  2. Somehow make the ClickHouse server respond with failure responses that are malformed. I could reproduce this by creating a high load on the server.
  3. If the failure response stream is not valid gzip it will throw when processing it in the onResponse callback:
  4. If there isn't a global unhandledRejection event handler registered it will make the node process exit with an error.

Expected behaviour

An error in failure response parsing should be propagated to the user instead.

Error log

node:internal/process/promises:394
    triggerUncaughtException(err, true /* fromPromise */);
    ^
Error: incorrect header check
    at genericNodeError (node:internal/errors:983:15)
    at wrappedFn (node:internal/errors:537:14)
    at Zlib.zlibOnError [as onerror] (node:zlib:185:17) {
  errno: -3,
  code: 'Z_DATA_ERROR'
}
Node.js v22.11.0

Configuration

Environment

  • Client version: 1.7.0
  • Language version: Node 22.11.0
  • OS: Linux

ClickHouse server

  • ClickHouse Server version: 24.8