Skip to content

Commit 99d3403

Browse files
shresthaoshanlewis-wow
authored andcommitted
update(forward.ts): timeout explicitly set
1 parent 4c8d8df commit 99d3403

1 file changed

Lines changed: 13 additions & 7 deletions

File tree

src/forward.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@ export const forward = async (
7171
lookup: handlerOpts.dnsLookup,
7272
};
7373

74+
const common_opts : https.RequestOptions | http.RequestOptions = {
75+
timeout: 200_000, // 200 seconds
76+
...options,
77+
}
78+
7479
// In case of proxy the path needs to be an absolute URL
7580
if (proxy) {
7681
options.path = request.url;
@@ -114,18 +119,19 @@ export const forward = async (
114119
resolve();
115120
} catch {
116121
// Client error, pipeline already destroys the streams, ignore.
117-
resolve();
122+
resolve();
118123
}
119124
};
120125

126+
const https_opts = {
127+
...common_opts,
128+
rejectUnauthorized: handlerOpts.upstreamProxyUrlParsed ? !handlerOpts.ignoreUpstreamProxyCertificate : undefined,
129+
}
130+
121131
// We have to force cast `options` because @types/node doesn't support an array.
122132
const client = origin!.startsWith('https:')
123-
? https.request(origin!, {
124-
...options as unknown as https.RequestOptions,
125-
rejectUnauthorized: handlerOpts.upstreamProxyUrlParsed ? !handlerOpts.ignoreUpstreamProxyCertificate : undefined,
126-
}, requestCallback)
127-
128-
: http.request(origin!, options as unknown as http.RequestOptions, requestCallback);
133+
? https.request(origin!, https_opts, requestCallback)
134+
: http.request(origin!, common_opts, requestCallback);
129135

130136
response.once('close', () => {
131137
const {

0 commit comments

Comments
 (0)