Skip to content

Commit 9d7e10c

Browse files
committed
Fix memory leaks in Driver class
- Remove waitForChannelReady from constructor to prevent Promise chain memory leaks - Add lazy initialization for discovery client (only created when needed) - Implement channel connectivity check in ready() method for non-discovery mode - Add test for memory leak prevention (100,000 Driver instances) - Use Promise.withResolvers() for cleaner promise handling - Properly handle AbortSignal cancellation in channel connectivity loop - Import ConnectivityState enum for type-safe state checks The main issue was that waitForChannelReady() in constructor created Promise chains with closures that held references to 'this', preventing garbage collection. Now channel connectivity is checked lazily only when ready() is called, and the promise chain is properly managed."
1 parent 46eff19 commit 9d7e10c

File tree

18 files changed

+161
-67
lines changed

18 files changed

+161
-67
lines changed

examples/api/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"@bufbuild/protobuf": "^2.6.0",
1717
"@ydbjs/api": "^6.0.0",
1818
"@ydbjs/auth": "^6.0.0",
19-
"@ydbjs/core": "^6.0.0"
19+
"@ydbjs/core": "^6.0.6"
2020
},
2121
"publishConfig": {
2222
"access": "restricted"

examples/auth-yandex-cloud/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
},
1616
"dependencies": {
1717
"@ydbjs/auth-yandex-cloud": "^0.1.2",
18-
"@ydbjs/core": "^6.0.0",
19-
"@ydbjs/query": "^6.0.0"
18+
"@ydbjs/core": "^6.0.6",
19+
"@ydbjs/query": "^6.0.6"
2020
},
2121
"publishConfig": {
2222
"access": "restricted"

examples/query/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
"dev": "DEBUG=ydbjs:* node index.js"
1414
},
1515
"dependencies": {
16-
"@ydbjs/core": "^6.0.0",
17-
"@ydbjs/query": "^6.0.0",
16+
"@ydbjs/core": "^6.0.6",
17+
"@ydbjs/query": "^6.0.6",
1818
"@ydbjs/value": "^6.0.0"
1919
},
2020
"publishConfig": {

examples/sls/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
},
1616
"dependencies": {
1717
"@ydbjs/auth": "^6.0.0",
18-
"@ydbjs/core": "^6.0.0",
19-
"@ydbjs/query": "^6.0.0"
18+
"@ydbjs/core": "^6.0.6",
19+
"@ydbjs/query": "^6.0.6"
2020
},
2121
"publishConfig": {
2222
"access": "restricted"

examples/tls/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"dependencies": {
1616
"@ydbjs/api": "^6.0.0",
1717
"@ydbjs/auth": "^6.0.0",
18-
"@ydbjs/core": "^6.0.0"
18+
"@ydbjs/core": "^6.0.6"
1919
},
2020
"publishConfig": {
2121
"access": "restricted"

examples/topic/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
"dev": "DEBUG=ydbjs:* node index.js"
1414
},
1515
"dependencies": {
16-
"@ydbjs/core": "^6.0.0",
17-
"@ydbjs/query": "^6.0.0",
18-
"@ydbjs/topic": "^6.0.0"
16+
"@ydbjs/core": "^6.0.6",
17+
"@ydbjs/query": "^6.0.6",
18+
"@ydbjs/topic": "^6.0.6"
1919
},
2020
"publishConfig": {
2121
"access": "restricted"

package-lock.json

Lines changed: 16 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
"attw": "turbo run attw",
2121
"test": "vitest --run",
2222
"lint": "oxlint",
23-
"publish-packages": "turbo run clean build attw test && changeset version && changeset publish"
23+
"version": "npx changeset version && npm install",
24+
"publish": "npx changeset publish"
2425
},
2526
"dependencies": {
2627
"@types/node": "^24.10.0"

packages/core/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# @ydbjs/core
22

3+
## 6.0.6
4+
5+
### Patch Changes
6+
7+
- Fix memory leaks in Driver class
8+
39
## 6.0.5
410

511
### Patch Changes

packages/core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@ydbjs/core",
3-
"version": "6.0.5",
3+
"version": "6.0.6",
44
"description": "Core driver for YDB: manages connections, endpoint discovery, authentication, and service client creation. Foundation for all YDB client operations.",
55
"keywords": [
66
"ydb",

0 commit comments

Comments
 (0)