Skip to content

Commit

Permalink
file_packager.py: Handle failure to get cached package (#21328)
Browse files Browse the repository at this point in the history
In certain scenarios (such as when quota is exceeded), it's possible for a metadata entry to exist, but the package data to be missing - and `event.target.result` will be undefined.

Check for and properly handle this by calling `errback`, so that the `preloadFallback` gets triggered.
  • Loading branch information
past-due authored Feb 22, 2024
1 parent 34c83d8 commit 0059aae
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions tools/file_packager.py
Original file line number Diff line number Diff line change
Expand Up @@ -914,6 +914,10 @@ def generate_js(data_target, data_files, metadata):
for (var chunkId = 0; chunkId < chunkCount; chunkId++) {
var getRequest = packages.get(`package/${packageName}/${chunkId}`);
getRequest.onsuccess = function(event) {
if (!event.target.result) {
errback(new Error(`CachedPackageNotFound for: ${packageName}`));
return;
}
// If there's only 1 chunk, there's nothing to concatenate it with so we can just return it now
if (chunkCount == 1) {
callback(event.target.result);
Expand Down

0 comments on commit 0059aae

Please sign in to comment.