File tree 2 files changed +11
-2
lines changed
2 files changed +11
-2
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ ' agent-base ' : patch
3
+ ---
4
+
5
+ Handle exceptions caused by Agent.addRequest()
Original file line number Diff line number Diff line change @@ -154,8 +154,12 @@ export abstract class Agent extends http.Agent {
154
154
( socket ) => {
155
155
this . decrementSockets ( name , fakeSocket ) ;
156
156
if ( socket instanceof http . Agent ) {
157
- // @ts -expect-error `addRequest()` isn't defined in `@types/node`
158
- return socket . addRequest ( req , connectOpts ) ;
157
+ try {
158
+ // @ts -expect-error `addRequest()` isn't defined in `@types/node`
159
+ return socket . addRequest ( req , connectOpts ) ;
160
+ } catch ( err : unknown ) {
161
+ return cb ( err as Error ) ;
162
+ }
159
163
}
160
164
this [ INTERNAL ] . currentSocket = socket ;
161
165
// @ts -expect-error `createSocket()` isn't defined in `@types/node`
You can’t perform that action at this time.
0 commit comments