All skills
clickhouse avatar

/clickhouse-js-node-troubleshooting

@faa5b11 official
by clickhouseclickhouse/agent-skills543 stars
39

Troubleshoot and resolve common issues with the ClickHouse Node.js client (@clickhouse/client). Use this skill whenever a user reports errors, unexpected behavior, or configuration questions involving the Node.js client specifically — including socket hang-up errors, Keep-Alive problems, stream handling issues, data type mismatches, read-only user restrictions, proxy/TLS setup problems, or long-running query timeouts. Trigger even when the user hasn't precisely named the issue; vague symptoms like "my inserts keep failing" or "connection drops randomly" in a Node.js context are strong signals to use this skill. Do NOT use for browser/Web client issues.

Use this Skill: https://skilld.dev/gh/clickhouse/agent-skills/clickhouse-js-node-troubleshooting

This session only. Nothing lands on disk.

referencequery-params.md

≈718 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Query Parameters Not Interpolated

Applies to: all versions. NULL parameter binding was fixed in 0.0.16. Tuple support via TupleParam wrapper and JS Map as a query parameter were added in >= 1.9.0. BigInt values in query parameters are supported since >= 1.15.0. Boolean formatting in Array/Tuple/Map params was fixed in >= 1.13.0.

Use the {name: type} syntax in the query string and pass values via query_params:

await client.query({
  query: "SELECT plus({val1: Int32}, {val2: Int32})",
  format: "CSV",
  query_params: { val1: 10, val2: 20 },
});

Never use template literals for user values

When $1/? don't work, a common instinct is to interpolate values directly with a template literal. Don't — this bypasses ClickHouse's server-side escaping and opens the door to SQL injection:

// ❌ Dangerous — never do this with user-controlled values
const userId = req.params.id;
await client.query({ query: `SELECT * FROM users WHERE id = ${userId}` });

// ✓ Safe — parameterized
await client.query({
  query: "SELECT * FROM users WHERE id = {id: UInt32}",
  query_params: { id: userId },
});

Always bring this up when answering query-params questions, especially when the user is coming from another database (PostgreSQL, MySQL, etc.) — they're the most likely to reach for template literals as a fallback.

Common mistake: wrong parameter syntax

The ClickHouse JS client uses ClickHouse's native {name: type} syntax — not $1/?/:name placeholders from other databases:

// ❌ Wrong — these don't work
await client.query({
  query: "SELECT * FROM t WHERE id = $1",
  query: "SELECT * FROM t WHERE id = ?",
  query: "SELECT * FROM t WHERE id = :id",
  query_params: { id: 42 },
});

// ✓ Correct
await client.query({
  query: "SELECT * FROM t WHERE id = {id: UInt32}",
  query_params: { id: 42 },
});

Array parameters

await client.query({
  query: "SELECT * FROM t WHERE id IN {ids: Array(UInt32)}",
  format: "JSONEachRow",
  query_params: { ids: [1, 2, 3] },
});

Tuple parameters (>= 1.9.0)

Use the TupleParam wrapper to pass a tuple:

import { TupleParam, createClient } from "@clickhouse/client";

const client = createClient({
  url: "http://localhost:8123",
});

await client.query({
  query: "SELECT {t: Tuple(UInt32, String)}",
  format: "JSONEachRow",
  query_params: { t: new TupleParam([42, "hello"]) },
});

Map parameters (>= 1.9.0)

Pass a JS Map directly:

await client.query({
  query: "SELECT {m: Map(String, UInt32)}",
  format: "JSONEachRow",
  query_params: { m: new Map([["key", 1]]) },
});

NULL parameters

Pass null directly — binding fixed in 0.0.16:

await client.query({
  query: "SELECT {val: Nullable(String)}",
  format: "JSONEachRow",
  query_params: { val: null },
});

Source: SKILL.md on GitHub

No alerts17d3 checks · Risk SAFE
  • Gen Agent Trust Hub17d

    This skill provides comprehensive troubleshooting documentation for the ClickHouse Node.js client. It includes security best practices, such as using parameterized queries to prevent SQL injection and clear warnings against insecure TLS configurations in production environments. No malicious patterns or security risks were detected.

  • Socket17d

    No alerts

  • Snyk17d

    Risk: LOW · No issues

Signed by skilld at faa5b11. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 3 days ago.

Activeupdated 3 months ago
  • clickhouse
  • nodejs
  • troubleshooting
  • client
  • socket
  • tls
  • compression
  • data-types
  • connection

README badge

README badge for clickhouse/agent-skills/clickhouse-js-node-troubleshooting

Diagnose and resolve common issues with the ClickHouse Node.js client (@clickhouse/client), including socket hang-ups, data type mismatches, TLS configuration problems, compression failures, and read-only user restrictions. Applies only to Node.js runtime environments, not browser or edge runtimes.

Generated from the current SKILL.md.

Does this skill work with the browser/Web client or just Node.js?
This skill covers only the Node.js runtime (@clickhouse/client), including Next.js Node API routes and Server Actions. For browser, Edge runtime, Cloudflare Workers, or Web Worker environments, use @clickhouse/client-web instead.
What kinds of errors does this skill help troubleshoot?
Socket hang-ups, ECONNRESET, data type mismatches, read-only user restrictions, proxy/TLS setup, compression issues, query timeouts, and query parameter interpolation problems with the ClickHouse Node.js client.
Do I need to know the exact error message to use this skill?
No. Vague symptoms like 'my inserts keep failing' or 'connection drops randomly' in a Node.js context are strong enough signals to trigger this skill.
Will this skill help with version compatibility issues?
Yes. The skill flags if a fix requires a minimum client version and will ask for your version if it's needed to recommend the right solution.

Generated from the current SKILL.md. These answers refresh after source changes.