1.20 alpha1#766
Conversation
When calling json() on a JSONEachRow result, the method first checks _stream.readableEnded and then calls stream() which checks readableEnded again. If the stream ends between these two checks (common with fast/small responses), stream() throws "Stream has been already consumed" even though this is the first consumption call. Fix by introducing a _consumed boolean flag that is set synchronously when any consumption method (text/json/stream) is called. This eliminates the race window between the two readableEnded checks. The fix splits stream() into a public method (with consumption check) and a private _streamImpl() (without check) that json() calls internally after already marking as consumed. This matches the pattern used by the web client's ResultSet which uses isAlreadyConsumed boolean instead of readableEnded. Fixes #575
readableEnded=true just means the 'end' event fired, NOT that someone already consumed the data. For fast/small responses, the stream can end before json() is even called, making readableEnded=true while data is still buffered and available. Checking readableEnded would reject the first consumption call — exactly the bug reported in #575. Only use the _consumed boolean flag, which tracks actual consumption by our code, not stream lifecycle events.
Address Copilot review feedback: 1. Move validateStreamFormat() before markAsConsumed() in stream(). Previously, if the format was invalid, the ResultSet was permanently marked as consumed even though nothing was actually read, preventing a subsequent text() call from working. 2. Make regression test deterministic by overriding readableEnded to always return true, simulating a fast response. The old code would throw on this; the new code only checks the _consumed flag.
Address reviewer feedback from peter-leonov-ch: Move `markAsConsumed()` from the top of `json()` into each branch that actually consumes the stream (streamable JSON and non-streamable JSON). The unsupported-format path (CSV, etc.) no longer marks the ResultSet as consumed, preserving the ability to call `text()` afterwards — matching the pre-PR exception semantics. Add tests verifying: - json() on CSV throws without marking consumed, text() still works - stream() on non-streamable format throws, text() still works
chore: bump version to 1.20.0
ci(tests): skip cloud integration jobs on fork PRs
…race Fix ResultSet.json() race condition on JSONEachRow streams
|
You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool. What Enabling Code Scanning Means:
For more information about GitHub Code Scanning, check out the documentation. |
|
|
There was a problem hiding this comment.
Pull request overview
This PR prepares a 1.20.0 release while fixing Node.js ResultSet consumption tracking and adjusting CI behavior for forked PRs.
Changes:
- Bumps package/runtime version metadata to
1.20.0. - Replaces Node
ResultSetconsumption checks based onreadableEndedwith an internal consumed flag. - Skips cloud integration jobs for forked PRs and updates the success aggregator to tolerate skipped jobs.
Reviewed changes
Copilot reviewed 10 out of 11 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
packages/client-node/src/result_set.ts |
Fixes ResultSet consumption tracking and stream validation order. |
packages/client-node/__tests__/unit/node_result_set.test.ts |
Adds regression and failure-path tests for ResultSet consumption behavior. |
.github/workflows/tests.yml |
Skips cloud tests for forked PRs and updates final success gating. |
packages/client-common/package.json |
Bumps common package version. |
packages/client-common/src/version.ts |
Bumps common runtime version. |
packages/client-node/package.json |
Bumps Node package version and common dependency. |
packages/client-node/src/version.ts |
Bumps Node runtime version. |
packages/client-web/package.json |
Bumps web package version and common dependency. |
packages/client-web/src/version.ts |
Bumps web runtime version. |
tests/clickhouse-test-runner/package.json |
Bumps test runner workspace version. |
package-lock.json |
Syncs workspace package versions and dependency metadata. |
facepalm.jpg
…ntu-x64 ci: run Copilot cloud agent on medium-runner-ubuntu-x64
Fix CI after the `ResultSet` consumption fix
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
## Summary Restrict npm publishing to a protected GitHub environment so release approvals/secrets can be gated centrally. - Add `environment: npm-publish` to the `head` and `latest` jobs in `.github/workflows/publish.yml`. - `e2e` is left unscoped — it only installs from the public registry. - No other changes needed: OIDC auth and `id-token: write` permissions remain at the job level. ## Checklist - [x] A human-readable description of the changes was provided to include in CHANGELOG CHANGELOG: Publish jobs now run under the `npm-publish` GitHub environment to enforce release protection rules. Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Peter Leonov <peter.leonov@clickhouse.com>
## Summary Upstream test `03262_system_functions_should_not_fill_query_log_functions` failed with `Syntax error (Multi-statements are not allowed)`. The `.sql` file begins with a `--` comment ending in `test's purpose.`; `splitQueries` treated the apostrophe as the start of a string literal, so subsequent `;` separators were ignored and all three statements were sent as one. - `tests/clickhouse-test-runner/src/split-queries.ts`: when not inside a quoted string, skip `-- ...` line comments (to end of line) and `/* ... */` block comments verbatim, so apostrophes/semicolons inside comments don't affect splitting. - `tests/clickhouse-test-runner/__tests__/split-queries.test.ts`: added cases for apostrophes/semicolons embedded in both line and block comments. ```sql -- defeat the test's purpose. SELECT 1; SYSTEM FLUSH LOGS query_log; SELECT 2; ``` Previously split into 1 statement; now correctly split into 3. ## Checklist - [x] Unit and integration tests covering the common scenarios were added - [x] A human-readable description of the changes was provided to include in CHANGELOG Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Peter Leonov <peter.leonov@clickhouse.com>
## Summary Document user-facing changes shipped since `1.19.0` under a new `1.20.0` section in `CHANGELOG.md`. - **Bug Fixes** - (Node.js) `ResultSet.json()` / `stream()` race on `JSONEachRow` where a fast response ending between `readableEnded` checks threw `Stream has been already consumed`. Consumption is now funneled through a single `consume()` path that marks the result set consumed in the appropriate branches, after format validation (#603). - **Improvements** - Re-export `ResponseHeaders` from `@clickhouse/client` and `@clickhouse/client-web`, continuing the move toward making `@clickhouse/client-common` internal-only (#758). Other commits in the `1.19.0..HEAD` range are CI/infra/test-only (publish env gating, copilot-setup-steps, fork cloud-test skip, test runner `splitQueries` fix, version bump, test-comment typo) and intentionally omitted. ## Checklist - [x] A human-readable description of the changes was provided to include in CHANGELOG Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
## Summary `playwright install` hangs indefinitely on Playwright `< 1.60.0` (microsoft/playwright#40998), causing GitHub Actions to cancel jobs during the Chromium download. Playwright was only present transitively as a peer dependency of `@vitest/browser-playwright`, resolving to `1.57.0` (root) and `1.59.1` (web example) — both affected. Changes: - **Pin Playwright** — add `playwright: "^1.60.0"` as a direct devDependency in `package.json` and `examples/web/package.json`, giving explicit version control over the previously transitive peer dep. - **Lockfiles** — regenerate `package-lock.json` and `examples/web/package-lock.json`; `playwright`/`playwright-core` now resolve to `1.60.0`. - **CI workflows** — no change needed; `.github/workflows/*` invoke `npx playwright install` with no pinned version, so they pick up the new resolved version automatically. No test logic or other dependencies were modified. ## Checklist - [x] A human-readable description of the changes was provided to include in CHANGELOG Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Pull request created by AI Agent Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
…784) The 1.20.0 changelog entry claimed `ResponseHeaders` was newly re-exported from `@clickhouse/client` and `@clickhouse/client-web`, but those re-exports already exist on the current entrypoints and are not modified by this release — the note belongs to 1.19.0. ## Summary - Removed the `ResponseHeaders` re-export bullet from the 1.20.0 section of `CHANGELOG.md`; 1.20.0 now lists only the `ResultSet.json()`/`stream()` race-condition fix that is actually shipped here. - Added the same bullet under 1.19.0 (where the re-export was introduced), along with its `[#758]` link reference. ## Checklist - [x] A human-readable description of the changes was provided to include in CHANGELOG Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
…lickHouse (#787) ## Summary Reran the upstream SQL test harness after merging `main`. All 3152 allowlisted tests pass against `clickhouse:head`; against `clickhouse:latest` (26.5.1.882) 5 tests fail because upstream test files on master reference server features not yet shipped in the released image. These are upstream-vs-server version skew, not client bugs, so they are commented out in `upstream-allowlist.txt` per the file's documented "remove or comment out with a reason" policy. - **Setting / column not in released CH** - `03701_limit_by_in_order` — uses setting `query_plan_push_limit_by_into_sort` - `03643_system_instrumentation_no_suspicious_lowcardinality` — uses `system.instrumentation.arguments` - **Join-optimizer reference output drift between master and `latest`** - `01031_pmj_new_any_semi_join` - `01031_semi_anti_join` - `03211_convert_outer_join_to_inner_join_anti_join` Each entry is preserved (commented out) with a one-line reason so it can be re-enabled once the released server catches up. ## Checklist - [x] A human-readable description of the changes was provided to include in CHANGELOG Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
#783) ## Summary First step toward deprecating `@clickhouse/client-common` so the platform packages can evolve their class hierarchies and types without being constrained by a shared base. Runtime values re-exported from `@clickhouse/client-common` are annotated with `@deprecated` JSDoc, while platform packages remain the recommended non-deprecated import path. Type-only exports are untouched. This PR also includes a follow-up fix from review feedback: the `ClickHouseClient` deprecation message in `packages/client-common/src/index.ts` was corrected to avoid implying a runtime import from `@clickhouse/client-web` (which exports `ClickHouseClient` as a type). The guidance now points to: - runtime imports from `@clickhouse/client` - type-only Web usage via `import type { ClickHouseClient } from '@clickhouse/client-web'` ### CHANGELOG entry Importing runtime values (`ClickHouseError`, `ClickHouseLogLevel`, `parseError`, `SettingsMap`, `TupleParam`, `isRow`, `isProgressRow`, `isException`, `parseColumnType`, `SimpleColumnTypes`, `defaultJSONHandling`, and the format-name constants) from `@clickhouse/client-common` is now deprecated; import them from `@clickhouse/client` or `@clickhouse/client-web` instead. For `ClickHouseClient`, use `@clickhouse/client` for runtime imports and `import type` from `@clickhouse/client-web` in Web projects. No runtime behavior change. ## Checklist - [ ] Unit and integration tests covering the common scenarios were added - [x] A human-readable description of the changes was provided to include in CHANGELOG - [ ] For significant changes, documentation in https://github.com/ClickHouse/clickhouse-docs was updated with further explanations or tutorials --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Summary
A short description of the changes with a link to an open issue.
Checklist
Delete items not relevant to your PR: