File tree Expand file tree Collapse file tree 2 files changed +10
-1
lines changed
Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -66,8 +66,8 @@ function Connection(options = {}) {
6666 ? socket . write ( frontend . Close ( ) )
6767 : socket . write ( frontend . Execute ( backend . query . cursor . rows ) )
6868 } ) . catch ( err => {
69- socket . write ( frontend . Close ( ) )
7069 backend . query . reject ( err )
70+ socket . write ( frontend . Close ( ) )
7171 } )
7272 }
7373
@@ -114,6 +114,7 @@ function Connection(options = {}) {
114114 }
115115
116116 function send ( query , { sig, str, args = [ ] } ) {
117+ try {
117118 query . str = str
118119 query . args = args
119120 query . result = [ ]
@@ -134,6 +135,9 @@ function Connection(options = {}) {
134135 open
135136 ? socket . write ( buffer )
136137 : ( messages . push ( buffer ) , connect ( ) )
138+ } catch ( err ) {
139+ query . reject ( err )
140+ }
137141 }
138142
139143 function connect ( ) {
Original file line number Diff line number Diff line change @@ -1084,3 +1084,8 @@ o('Catches connection config errors', async() => {
10841084 await sql `select 1` . catch ( ( e ) => e . message )
10851085 ]
10861086} )
1087+
1088+ o ( 'Catches query format errors' , async ( ) => [
1089+ 'wat' ,
1090+ await sql . unsafe ( { toString : ( ) => { throw new Error ( 'wat' ) } } ) . catch ( ( e ) => e . message )
1091+ ] )
You can’t perform that action at this time.
0 commit comments