Skip to content

Commit

Permalink
Desktop: Fixes #10740: Improve the reliability of fetching resources (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
pedr authored Aug 5, 2024
1 parent 60e347a commit a6cf0a3
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/lib/shim-init-node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,7 @@ function shimInit(options: ShimInitOptions = null) {
cleanUpOnError(error);
});

const requestStart = new Date();
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied
const request = http.request(requestOptions, (response: any) => {

Expand Down Expand Up @@ -629,7 +630,10 @@ function shimInit(options: ShimInitOptions = null) {
});

request.on('timeout', () => {
request.destroy(new Error(`Request timed out. Timeout value: ${requestOptions.timeout}ms.`));
// We choose to not destroy the request when a timeout value is not specified to keep
// the behavior we had before the addition of this event handler.
if (!requestOptions.timeout) return;
request.destroy(new Error(`Request timed out. Timeout value: ${requestOptions.timeout}ms. Actual connection time: ${new Date().getTime() - requestStart.getTime()}ms`));
});

// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied
Expand Down

0 comments on commit a6cf0a3

Please sign in to comment.