diff --git a/src/table.ts b/src/table.ts index a31f1d05..4293eb3a 100644 --- a/src/table.ts +++ b/src/table.ts @@ -47,6 +47,7 @@ import ExecuteScanQueryPartialResult = Ydb.Table.ExecuteScanQueryPartialResult; import IKeyRange = Ydb.Table.IKeyRange; import TypedValue = Ydb.TypedValue; import BulkUpsertResult = Ydb.Table.BulkUpsertResult; +import OperationMode = Ydb.Operations.OperationParams.OperationMode; interface PartialResponse { status?: (Ydb.StatusIds.StatusCode|null); @@ -100,19 +101,19 @@ interface IQueryParams { } export class OperationParams implements Ydb.Operations.IOperationParams { - operationMode?: Ydb.Operations.OperationParams.OperationMode; + operationMode?: OperationMode; operationTimeout?: google.protobuf.IDuration; cancelAfter?: google.protobuf.IDuration; labels?: { [k: string]: string }; reportCostInfo?: Ydb.FeatureFlag.Status; withSyncMode() { - this.operationMode = Ydb.Operations.OperationParams.OperationMode.SYNC; + this.operationMode = OperationMode.SYNC; return this; } withAsyncMode() { - this.operationMode = Ydb.Operations.OperationParams.OperationMode.ASYNC; + this.operationMode = OperationMode.ASYNC; return this; } @@ -377,7 +378,11 @@ export class Session extends EventEmitter implements ICreateSessionResult { @retryable() @pessimizable - public async alterTable(tablePath: string, description: AlterTableDescription, settings?: AlterTableSettings): Promise { + public async alterTable( + tablePath: string, + description: AlterTableDescription, + settings?: AlterTableSettings + ): Promise { const request: Ydb.Table.IAlterTableRequest = { ...description, sessionId: this.sessionId, @@ -386,8 +391,15 @@ export class Session extends EventEmitter implements ICreateSessionResult { if (settings) { request.operationParams = settings.operationParams; } + + // !! does not returns response if async operation mode const response = await this.api.alterTable(request); - ensureOperationSucceeded(this.processResponseMetadata(request, response)); + try { + ensureOperationSucceeded(this.processResponseMetadata(request, response)); + } catch (error) { + if (request.operationParams?.operationMode !== OperationMode.SYNC && error instanceof MissingStatus) { + } else throw error; + } } /*