File tree Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -353,7 +353,7 @@ module.exports = interceptorOpts => {
353
353
354
354
instance . runLookup ( origin , origDispatchOpts , ( err , newOrigin ) => {
355
355
if ( err ) {
356
- return handler . onError ( err )
356
+ return handler . onResponseError ( null , err )
357
357
}
358
358
359
359
let dispatchOpts = null
Original file line number Diff line number Diff line change @@ -1865,3 +1865,28 @@ test('#3937 - Handle host correctly', async t => {
1865
1865
t . equal ( response2 . statusCode , 200 )
1866
1866
t . equal ( await response2 . body . text ( ) , 'hello world!' )
1867
1867
} )
1868
+
1869
+ test ( '#3951 - Should handle lookup errors correctly' , async t => {
1870
+ const suite = tspl ( t , { plan : 1 } )
1871
+
1872
+ const requestOptions = {
1873
+ method : 'GET' ,
1874
+ path : '/' ,
1875
+ headers : {
1876
+ 'content-type' : 'application/json'
1877
+ }
1878
+ }
1879
+
1880
+ const client = new Agent ( ) . compose ( [
1881
+ dns ( {
1882
+ lookup : ( _origin , _opts , cb ) => {
1883
+ cb ( new Error ( 'lookup error' ) )
1884
+ }
1885
+ } )
1886
+ ] )
1887
+
1888
+ suite . rejects ( client . request ( {
1889
+ ...requestOptions ,
1890
+ origin : 'http://localhost'
1891
+ } ) , new Error ( 'lookup error' ) )
1892
+ } )
You can’t perform that action at this time.
0 commit comments