Skip to content

Commit 4edc46a

Browse files
authored
1 parent d0b83e6 commit 4edc46a

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/vs/platform/request/node/requestService.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,23 @@ export async function nodeRequest(options: NodeRequestOptions, token: Cancellati
201201

202202
req.on('error', reject);
203203

204+
// Handle timeout
204205
if (options.timeout) {
205-
req.setTimeout(options.timeout);
206+
// Chromium network requests do not support the `timeout` option
207+
if (options.isChromiumNetwork) {
208+
// Use Node's setTimeout for Chromium network requests
209+
const timeout = setTimeout(() => {
210+
req.abort();
211+
reject(new Error(`Request timeout after ${options.timeout}ms`));
212+
}, options.timeout);
213+
214+
// Clear timeout when request completes
215+
req.on('response', () => clearTimeout(timeout));
216+
req.on('error', () => clearTimeout(timeout));
217+
req.on('abort', () => clearTimeout(timeout));
218+
} else {
219+
req.setTimeout(options.timeout);
220+
}
206221
}
207222

208223
// Chromium will abort the request if forbidden headers are set.

0 commit comments

Comments
 (0)