Skip to content

Commit 2d4a83f

Browse files
shresthaoshanlewis-wow
authored andcommitted
update(forward.ts): timeout explicitly set
1 parent bf1d68f commit 2d4a83f

1 file changed

Lines changed: 12 additions & 10 deletions

File tree

src/forward.ts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,11 @@ export const forward = async (
7373
lookup: handlerOpts.dnsLookup,
7474
};
7575

76+
const commonOpts: http.RequestOptions = {
77+
timeout: 200_000, // 200 seconds
78+
...options,
79+
};
80+
7681
// In case of proxy the path needs to be an absolute URL
7782
if (proxy) {
7883
options.path = request.url;
@@ -120,18 +125,15 @@ export const forward = async (
120125
}
121126
};
122127

128+
const httpsOpts = {
129+
...commonOpts,
130+
rejectUnauthorized: handlerOpts.upstreamProxyUrlParsed ? !handlerOpts.ignoreUpstreamProxyCertificate : undefined,
131+
};
132+
123133
// We have to force cast `options` because @types/node doesn't support an array.
124134
const client = origin!.startsWith('https:')
125-
? https.request(origin!, {
126-
...options as unknown as https.RequestOptions,
127-
rejectUnauthorized: handlerOpts.upstreamProxyUrlParsed ? !handlerOpts.ignoreUpstreamProxyCertificate : undefined,
128-
agent: handlerOpts.httpsAgent,
129-
}, requestCallback)
130-
131-
: http.request(origin!, {
132-
...options as unknown as http.RequestOptions,
133-
agent: handlerOpts.httpAgent,
134-
}, requestCallback);
135+
? https.request(origin!, httpsOpts, requestCallback)
136+
: http.request(origin!, commonOpts, requestCallback);
135137

136138
response.once('close', () => {
137139
const {

0 commit comments

Comments
 (0)