Skip to content

Commit 3026855

Browse files
committed
Fix discovery client undefined check
- Replace null check with nullish coalescing to handle undefined - Convert getter to method and fix method call syntax - Prevents TypeError when accessing listEndpoints on undefined client
1 parent e2a20be commit 3026855

File tree

13 files changed

+45
-25
lines changed

13 files changed

+45
-25
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.6"
19+
"@ydbjs/core": "^6.0.7"
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.6",
19-
"@ydbjs/query": "^6.0.6"
18+
"@ydbjs/core": "^6.0.7",
19+
"@ydbjs/query": "^6.0.7"
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.6",
17-
"@ydbjs/query": "^6.0.6",
16+
"@ydbjs/core": "^6.0.7",
17+
"@ydbjs/query": "^6.0.7",
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.6",
19-
"@ydbjs/query": "^6.0.6"
18+
"@ydbjs/core": "^6.0.7",
19+
"@ydbjs/query": "^6.0.7"
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.6"
18+
"@ydbjs/core": "^6.0.7"
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.6",
17-
"@ydbjs/query": "^6.0.6",
18-
"@ydbjs/topic": "^6.0.6"
16+
"@ydbjs/core": "^6.0.7",
17+
"@ydbjs/query": "^6.0.7",
18+
"@ydbjs/topic": "^6.0.7"
1919
},
2020
"publishConfig": {
2121
"access": "restricted"

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.7
4+
5+
### Patch Changes
6+
7+
- Fix discovery client undefined check
8+
39
## 6.0.6
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.6",
3+
"version": "6.0.7",
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",

packages/core/src/driver.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -230,14 +230,10 @@ export class Driver implements Disposable {
230230
return this.cs.protocol === 'https:' || this.cs.protocol === 'grpcs:'
231231
}
232232

233-
get #getDiscoveryClient(): Client<typeof DiscoveryServiceDefinition> {
234-
if (this.#discoveryClient === null) {
235-
dbg.log('creating discovery client')
236-
this.#discoveryClient = createClientFactory()
237-
.use(this.#middleware)
238-
.create(DiscoveryServiceDefinition, this.#connection.channel)
239-
}
240-
return this.#discoveryClient
233+
#getDiscoveryClient(): Client<typeof DiscoveryServiceDefinition> {
234+
return (this.#discoveryClient ??= createClientFactory()
235+
.use(this.#middleware)
236+
.create(DiscoveryServiceDefinition, this.#connection.channel))
241237
}
242238

243239
async #discovery(signal: AbortSignal): Promise<void> {
@@ -253,7 +249,7 @@ export class Driver implements Disposable {
253249

254250
let result = await retry(retryConfig, async (signal) => {
255251
dbg.log('attempting to list endpoints for database: %s', this.database)
256-
let response = await this.#getDiscoveryClient.listEndpoints({ database: this.database }, { signal })
252+
let response = await this.#getDiscoveryClient().listEndpoints({ database: this.database }, { signal })
257253
if (!response.operation) {
258254
throw new ClientError(
259255
DiscoveryServiceDefinition.listEndpoints.path,

packages/query/CHANGELOG.md

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

3+
## 6.0.7
4+
5+
### Patch Changes
6+
7+
- Fix discovery client undefined check
8+
9+
- Updated dependencies []:
10+
- @ydbjs/core@6.0.7
11+
312
## 6.0.6
413

514
### Patch Changes

0 commit comments

Comments
 (0)