Skip to content

Commit ba82237

Browse files
committed
[file_packager] Remove unused errback fetchRemovePackage. NFC
This argument has basically used since 3839dd4. Even when this function was first add in 74f3242 the errback callback was only used for the IDB failures, not the fetch failures. Fetch failure were left to propagate to the global error handlers. The exception here was that when node support was added in #11785 it, I believe incorrectly used errback to handle file read errors (doesn't match the web version that does *not* handle fetch error using errback). This is small cleanup in advance of #24893.
1 parent 9aeb3f0 commit ba82237

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

tools/file_packager.py

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -953,18 +953,12 @@ def generate_js(data_target, data_files, metadata):
953953
if options.support_node:
954954
node_support_code = '''
955955
if (isNode) {
956-
require('fs').readFile(packageName, (err, contents) => {
957-
if (err) {
958-
errback(err);
959-
} else {
960-
callback(contents.buffer);
961-
}
962-
});
956+
require('fs/promises').readFile(packageName).then((contents) => callback(contents.buffer));
963957
return;
964958
}'''.strip()
965959

966960
ret += '''
967-
function fetchRemotePackage(packageName, packageSize, callback, errback) {
961+
function fetchRemotePackage(packageName, packageSize, callback) {
968962
%(node_support_code)s
969963
Module['dataFileDownloads'] ??= {};
970964
fetch(packageName)
@@ -1040,7 +1034,7 @@ def generate_js(data_target, data_files, metadata):
10401034
function preloadFallback(error) {
10411035
console.error(error);
10421036
console.error('falling back to default preload behavior');
1043-
fetchRemotePackage(REMOTE_PACKAGE_NAME, REMOTE_PACKAGE_SIZE, processPackageData, handleError);
1037+
fetchRemotePackage(REMOTE_PACKAGE_NAME, REMOTE_PACKAGE_SIZE, processPackageData);
10441038
};
10451039
10461040
openDatabase()
@@ -1059,8 +1053,7 @@ def generate_js(data_target, data_files, metadata):
10591053
console.error(error);
10601054
processPackageData(packageData);
10611055
});
1062-
}
1063-
, preloadFallback);
1056+
});
10641057
}
10651058
})
10661059
}).catch(preloadFallback);
@@ -1082,7 +1075,7 @@ def generate_js(data_target, data_files, metadata):
10821075
} else {
10831076
fetched = data;
10841077
}
1085-
}, handleError);\n'''
1078+
});\n'''
10861079

10871080
code += '''
10881081
Module['preloadResults'][PACKAGE_NAME] = {fromCache: false};

0 commit comments

Comments
 (0)