@clickhouse/client 1.18.1
Improvements
- Setting
log.leveldefault value toClickHouseLogLevel.WARNinstead ofClickHouseLogLevel.OFFto provide better visibility into potential issues without overwhelming users with too much information by default.
const client = createClient({
// ...
log: {
level: ClickHouseLogLevel.WARN, // default is now ClickHouseLogLevel.WARN instead of ClickHouseLogLevel.OFF
},
})
- Logging is now lazy, which means that the log messages will only be constructed if the log level is appropriate for the message. This can improve performance in cases where constructing the log message is expensive, and the log level is set to ignore such messages. See
ClickHouseLogLevelenum for the complete list of log levels. (#520)
const client = createClient({
// ...
log: {
level: ClickHouseLogLevel.TRACE, // to log everything available down to the network level events
},
})
- Enhanced the logging of the HTTP request / socket lifecycle with additional trace messages and context such as Connection ID (UUID) and Request ID and Socket ID that embed the connection ID for ease of tracing the logs of a particular request across the connection lifecycle. To enable such logs, set the
log.levelconfig option toClickHouseLogLevel.TRACE. (#567)
[2026-02-25T09:19:13.511Z][TRACE][@clickhouse/client][Connection] Insert: received 'close' event, 'free' listener removed
Arguments: {
operation: 'Insert',
connection_id: 'da3c9796-5dc5-46ef-83b0-ed1f4422094c',
query_id: '9dfda627-39a2-41a6-9fc9-8f8716574826',
request_id: 'da3c9796-5dc5-46ef-83b0-ed1f4422094c:3',
socket_id: 'da3c9796-5dc5-46ef-83b0-ed1f4422094c:2',
event: 'close'
}
[2026-02-25T09:19:13.502Z][TRACE][@clickhouse/client][Connection] Query: reusing socket
Arguments: {
operation: 'Query',
connection_id: 'da3c9796-5dc5-46ef-83b0-ed1f4422094c',
query_id: 'ad0127e8-b1c7-4ed6-9681-c0162f7a0ea9',
request_id: 'da3c9796-5dc5-46ef-83b0-ed1f4422094c:4',
socket_id: 'da3c9796-5dc5-46ef-83b0-ed1f4422094c:2',
usage_count: 1
}
- A step towards structured logging: the client now passes rich context to the logger
argsparameter (e.g.connection_id,query_id,request_id,socket_id). (#576)
Deprecated API
-
The
drainStreamutility function is now deprecated, as the client will handle draining the stream internally when needed. Useclient.command()instead, which will handle draining the stream internally when needed. (#578) -
The
sleeputility function is now deprecated, as it is not intended to be used outside of the client implementation. UsesetTimeoutdirectly or a more full-featured utility library if you need additional features like cancellation or timers management. (#578)