File tree Expand file tree Collapse file tree 2 files changed +7
-9
lines changed
Expand file tree Collapse file tree 2 files changed +7
-9
lines changed Original file line number Diff line number Diff line change @@ -18,18 +18,16 @@ class Database {
1818 }
1919
2020 async query ( sql , args ) {
21- const connection = await this . getConnection ( ) ;
22- let isDestroyed = false ;
2321 try {
24- const result = await connection . query ( sql , args ) ;
22+ const connection = await this . getConnection ( ) ;
23+ let result ;
24+ await this . withNewTransaction ( connection , async ( ) => {
25+ result = await connection . query ( sql , args ) ;
26+ } ) ;
2527 return result [ 0 ] ;
2628 } catch ( error ) {
2729 console . log ( "SQL ERROR SQL ERROR SQL ERROR SQL ERROR SQL ERROR\n" + error ) ;
28- if ( error . toString ( ) . includes ( "closed state" ) ) isDestroyed = true ;
2930 throw error ;
30- } finally {
31- if ( isDestroyed ) connection . destroy ( ) ;
32- else connection . release ( ) ;
3331 }
3432 }
3533
@@ -81,7 +79,7 @@ class Database {
8179 } ) ;
8280 } catch ( err ) {
8381 console . log ( "Failed to import users. Error: " + err ) ;
84- }
82+ }
8583 }
8684}
8785
Original file line number Diff line number Diff line change 11{
22 "name" : " g5api" ,
3- "version" : " 1.2.0" ,
3+ "version" : " 1.2.0.1 " ,
44 "private" : true ,
55 "licenses" : [
66 {
You can’t perform that action at this time.
0 commit comments