|
1 | 1 | import type { Abortable } from 'node:events'
|
2 | 2 |
|
3 | 3 | import { StatusIds_StatusCode } from '@ydbjs/api/operation'
|
4 |
| -import { QueryServiceDefinition, type SessionState } from '@ydbjs/api/query' |
| 4 | +import { QueryServiceDefinition } from '@ydbjs/api/query' |
5 | 5 | import type { Driver } from '@ydbjs/core'
|
6 | 6 | import { CommitError, YDBError } from '@ydbjs/error'
|
7 | 7 | import { defaultRetryConfig, isRetryableError, retry } from '@ydbjs/retry'
|
@@ -149,21 +149,10 @@ export function query(driver: Driver): QueryClient {
|
149 | 149 |
|
150 | 150 | client = driver.createClient(QueryServiceDefinition, sessionResponse.nodeId)
|
151 | 151 |
|
152 |
| - let attachSession = Promise.withResolvers<SessionState>() |
153 |
| - ; (async (stream: AsyncIterable<SessionState>) => { |
154 |
| - try { |
155 |
| - for await (let state of stream) { |
156 |
| - signal.throwIfAborted() |
157 |
| - attachSession.resolve(state) |
158 |
| - } |
159 |
| - } catch (err) { |
160 |
| - attachSession.reject(err) |
161 |
| - } |
162 |
| - })(client.attachSession({ sessionId: store.sessionId }, { signal })) |
163 |
| - |
164 |
| - let attachSessionResult = await attachSession.promise |
165 |
| - if (attachSessionResult.status !== StatusIds_StatusCode.SUCCESS) { |
166 |
| - throw new YDBError(attachSessionResult.status, attachSessionResult.issues) |
| 152 | + let attachSession = client.attachSession({ sessionId: store.sessionId })[Symbol.asyncIterator]() |
| 153 | + let attachSessionResult = await attachSession.next() |
| 154 | + if (attachSessionResult.value.status !== StatusIds_StatusCode.SUCCESS) { |
| 155 | + throw new YDBError(attachSessionResult.value.status, attachSessionResult.value.issues) |
167 | 156 | }
|
168 | 157 |
|
169 | 158 | let beginTransactionResult = await client.beginTransaction({
|
|
0 commit comments