1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-24 10:27:10 +02:00

Desktop: Fixes #10740: Improve the reliability of fetching resources (#10826)

This commit is contained in:
pedr 2024-08-05 15:36:54 -03:00 committed by GitHub
parent 60e347a782
commit a6cf0a3a81
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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) => {
@ -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