This repository was archived by the owner on Mar 4, 2026. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1774,7 +1774,7 @@ export class Transaction extends Dml {
17741774 } else if ( ! this . _useInRunner ) {
17751775 reqOpts . singleUseTransaction = this . _options ;
17761776 } else {
1777- this . begin ( ) . then ( ( ) => this . commit ( options , callback ) ) ;
1777+ this . begin ( ) . then ( ( ) => this . commit ( options , callback ) , callback ) ;
17781778 return ;
17791779 }
17801780
Original file line number Diff line number Diff line change @@ -3382,6 +3382,30 @@ describe('Spanner with mock server', () => {
33823382 } ) as v1 . BeginTransactionRequest ;
33833383 assert . ok ( beginTxnRequest , 'beginTransaction was called' ) ;
33843384 } ) ;
3385+
3386+ it ( 'should throw error if begin transaction fails on blind commit' , async ( ) => {
3387+ const database = newTestDatabase ( ) ;
3388+ const err = {
3389+ message : 'Test error' ,
3390+ } as MockError ;
3391+ spannerMock . setExecutionTime (
3392+ spannerMock . beginTransaction ,
3393+ SimulatedExecutionTime . ofError ( err )
3394+ ) ;
3395+ try {
3396+ await database . runTransactionAsync ( async tx => {
3397+ tx . insert ( 'foo' , { id : 1 , name : 'One' } ) ;
3398+ await tx . commit ( ) ;
3399+ } ) ;
3400+ } catch ( e ) {
3401+ assert . strictEqual (
3402+ ( e as ServiceError ) . message ,
3403+ '2 UNKNOWN: Test error'
3404+ ) ;
3405+ } finally {
3406+ await database . close ( ) ;
3407+ }
3408+ } ) ;
33853409 } ) ;
33863410
33873411 describe ( 'table' , ( ) => {
You can’t perform that action at this time.
0 commit comments