Repository navigation
fix(client-node): stop an aborted waiting request from destroying a socket in use - #1041
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The new changelog version does not match the package metadata.
1 open finding
What changed in this PR
Fixes orphaned idle-socket timers when queued requests are aborted.
Changes:
- Clears the previous timer on repeated
freeevents. - Adds a regression test and changelog entry.
| File | Description |
|---|---|
socket_pool.ts |
Clears stale idle timers. |
node_abort_queued_request.test.ts |
Covers the socket-reuse regression. |
CHANGELOG.md |
Documents the fix. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
vvo
marked this pull request as ready for review
October 8, 2026 10:30
peter-leonov-ch
approved these changes
Oct 9, 2026
Merged
1 task done
kavirajk
pushed a commit
that referenced
this pull request
Oct 22, 2026
…rly (#1076) ## Summary Runs the ClickHouse Cloud integration tests after a PR is merged, or on request, instead of on every push to every PR. Also runs them one job at a time. This follows what [clickhouse-go](https://github.com/ClickHouse/clickhouse-go/blob/main/.github/workflows/run-tests-cloud.yml) does against the same Cloud service. ### Why The Cloud jobs use one ClickHouse Cloud service, which is shared with other client repositories (clickhouse-go uses the same `INTEGRATIONS_TEAM_TESTS_CLOUD_HOST_SMT_PROD` secret). On Cloud, every test file creates its own database, and `clean-up.yml` only drops databases older than 60 minutes. Each push to a PR started six Cloud jobs at once. Pushing a stack of eight PRs (#1065 to #1072) twice within 15 minutes filled the service: ``` Too many databases. The limit (max_database_num_to_throw) is set to 2800, the current number of databases is 2800. (code 725) ``` From then on, every Cloud job, including #1075's, failed during setup before running any tests. This likely affects the other repositories that use the same service too. ### What - **New `tests-cloud.yml`** with the Node.js and Web Cloud jobs, which are removed from `tests-node.yml` and `tests-web.yml`. It runs: - after a merge (push to `main` or `release`, with the same path filters as before), on the daily schedule, and on `workflow_dispatch`; - on a PR only when a maintainer adds the **`tests:run-cloud`** label. A final job removes the label, so adding it again runs the tests again. - **One Cloud job at a time across the repository:** - one workflow-level concurrency group, `tests-cloud`, with `cancel-in-progress: false`, so a whole run holds the lock and other runs wait. Of the waiting runs, only the newest is kept. - within a run, `max-parallel: 1` runs the matrix jobs one by one, and the Web jobs wait for the Node.js jobs. - runs whose jobs will be skipped, for example a PR that got a different label, get a group of their own (`tests-cloud-skipped-<run id>`), so they can't replace a waiting Cloud run. - **`examples.yml` passes the Cloud credentials only after a merge and on manual runs.** On PRs they're empty, so the `create_table_cloud` example (Node.js and Web) skips itself, which it already did when the credentials were missing. Before this, each of the 4 examples jobs of every PR hit the Cloud service. With the lexer stack's PRs running at once, that example timed out in 28 jobs. - **`clean-up.yml` runs hourly instead of on every push.** It used to run on every push to every branch, and a new push cancelled one still in progress. Dropping databases one by one takes a while, so a burst of pushes kept restarting it. It now runs at :17 every hour, which also puts a run before the 09:00 scheduled Cloud tests, and on demand (`workflow_dispatch`). Only one runs at a time, and a running cleanup is never cancelled. - **Fork and Dependabot PRs are still skipped**, as before, because Cloud secrets aren't available to them. It uses `pull_request`, not `pull_request_target`, so a PR's code never runs with secrets unless it comes from a branch in this repository. - **`npm ci` instead of `npm install`** in the new workflow, so dependencies are installed exactly as locked, verified by hash. This resolves the Scorecard Pinned-Dependencies alerts on these two steps. The other workflows still use `npm install`, so their existing alerts are unchanged. - **`codecov.yml`:** `after_n_builds` goes from 7 to 5, the uploads every PR gets. With 7, Codecov never posted a status on fork PRs (for example #1041 and #1024), which skip the Cloud jobs, and with this change it wouldn't post on most PRs. The cloud flags are carried forward (`carryforward: true` was already set). ### Trade-offs - **Cloud regressions show up after merge** (on `main`), unless the label is added before merging. - **A Cloud run takes longer** with jobs one at a time: 4 Node.js versions and then 2 browsers, about 25–30 minutes instead of about 5. - **The `tests:run-cloud` label is new.** I've created it in the repository. ## Testing - All workflow and Codecov YAML parses, and Prettier passes. `actionlint` wasn't available locally. - The new workflow can only really be checked on GitHub: after merge (push to `main`), and by adding `tests:run-cloud` to a PR once the Cloud service has been cleaned up. ## Checklist - [x] CI only; no changelog entry needed. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

tl;dr; stops
socket hang uperrors after an aborted request, by clearing the previous idle-socket timer when a socket is released a second time.Problem
max_open_connectionssockets are busy, new requests wait for one. If a waiting request is aborted, Node.js releases the next free socket twice: once for the request that finished, once for the aborted one.idle_timeout_handlewithout clearing the previous timer. The first timer firesidle_socket_ttllater and destroys the socket while another request is using it.Solution
Implementation details
onSocketNTin Node's_http_client.js, which emitsfreeon the socket it hands to an already-destroyed request.max_open_connections: 1: one request holds the socket, a waiting request is aborted, and a third request runs past the release plus the TTL. It fails onmainwithsocket hang upand passes with the fix.socket hang uperrors per hour once requests started waiting for sockets.@clickhouse/client.