Desktop: Fixes #10740: Improve the reliability of fetching resources #10826
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes: #10740
Summary
As reported by the user, the new code, when
timeout
is set to undefined, uses thehttp.globalAgent
which has a default timeout to 5 seconds.Previously, this wouldn't be a problem because we didn't have an event handler for
timeout
event, so now I'm checking if the timeout was specified for this request, and if it wasn't I opt to not destroy the request.I also added more information to the log message when the request timeout.
Testing
To test this change I created a simple HTTP server, with a sleep function in the endpoint that returns one of the images from a static HTML page.
After that, I used the Web Clipper to save the full HTML page, which will use the
fetchBlob
function to download the image.The sleep function should be higher than the timeout value, if that happens we can see the
timeout
event being generated.