fix: url upload fetch timeout failsafe

This commit is contained in:
Bobby 2022-09-14 06:04:18 +07:00
parent 93dc820368
commit cc5625fabf
No known key found for this signature in database
GPG Key ID: 941839794CBF5A09

View File

@ -613,6 +613,11 @@ self.actuallyUploadUrls = async (req, res, data = {}) => {
// Reduce GET timeout by time already spent for HEAD request
const _timeout = urlFetchTimeout - (Date.now() - headStart)
// Skip early if HEAD fetch took too long
if (_timeout <= 0) {
throw new ClientError('Fetch timed out. Try again?')
}
const fetchFile = await utils.fetch(url, {
method: 'GET',
size: urlMaxSizeBytes, // limit max response body size