Purge cache on failure.

pull/500/head
Mikunj 6 years ago
parent 0636e635d5
commit a9710a68db

@ -79,7 +79,16 @@
}
// Start the request
const promise = _getPreview(url);
const promise = _getPreview(url).catch(e => {
window.log.error(e);
// If we get an error then we can purge the cache
if (url in previewCache) {
delete previewCache[url];
}
return null;
});
previewCache[url] = promise;
return promise;
@ -91,7 +100,7 @@
html = await textsecure.messaging.makeProxiedRequest(url);
} catch (error) {
if (error.code >= 300) {
return null;
throw new Error(`Failed to fetch html: ${error}`);
}
}

Loading…
Cancel
Save