Skip to content

Commit 0059aae

Browse files
authored
file_packager.py: Handle failure to get cached package (#21328)
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.
1 parent 34c83d8 commit 0059aae

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

tools/file_packager.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -914,6 +914,10 @@ def generate_js(data_target, data_files, metadata):
914914
for (var chunkId = 0; chunkId < chunkCount; chunkId++) {
915915
var getRequest = packages.get(`package/${packageName}/${chunkId}`);
916916
getRequest.onsuccess = function(event) {
917+
if (!event.target.result) {
918+
errback(new Error(`CachedPackageNotFound for: ${packageName}`));
919+
return;
920+
}
917921
// If there's only 1 chunk, there's nothing to concatenate it with so we can just return it now
918922
if (chunkCount == 1) {
919923
callback(event.target.result);

0 commit comments

Comments
 (0)