Add timeout to extensions auto-update

4376d66b33f53cdd0a64afc66ce1ccf5dc8ef36c

Cohee <18619528+Cohee1207@users.noreply.github.com>

1 files changed, +7 -3Ignore whitespace
public/scripts/extensions.js+7 -3
@@ -976,11 +976,14 @@ async function onUpdateClick() {
976976 * Updates a third-party extension via the API.
977977 * @param {string} extensionName Extension folder name
978978 * @param {boolean} quiet If true, don't show a success message
979+ * @param {number?} timeout Timeout in milliseconds to wait for the update to complete. If null, no timeout is set.
979980 */
980981async function updateExtension(extensionName, quiet, timeout = null) {
981982 try {
983+ const signal = timeout ? AbortSignal.timeout(timeout) : undefined;
982984 const response = await fetch('/api/extensions/update', {
983985 method: 'POST',
986+ signal: signal,
984987 headers: getRequestHeaders(),
985988 body: JSON.stringify({
986989 extensionName,
@@ -1009,7 +1012,7 @@ async function updateExtension(extensionName, quiet) {
10091012 toastr.success(t`Extension ${extensionName} updated to ${data.shortCommitHash}`, t`Reload the page to apply updates`);
10101013 }
10111014 } catch (error) {
10121015 console.error('ErrorExtension update error:', error);
10131016 }
10141017}
10151018
@@ -1480,6 +1483,7 @@ async function autoUpdateExtensions(forceAll) {
14801483 const banner = toastr.info(t`Auto-updating extensions. This may take several minutes.`, t`Please wait...`, { timeOut: 10000, extendedTimeOut: 10000 });
14811484 const isCurrentUserAdmin = isAdmin();
14821485 const promises = [];
1486+ const autoUpdateTimeout = 60 * 1000;
14831487 for (const [id, manifest] of Object.entries(manifests)) {
14841488 const isDisabled = extension_settings.disabledExtensions.includes(id);
14851489 if (!forceAll && isDisabled) {
@@ -1493,7 +1497,7 @@ async function autoUpdateExtensions(forceAll) {
14931497 }
14941498 if ((forceAll || manifest.auto_update) && id.startsWith('third-party')) {
14951499 console.debug(`Auto-updating 3rd-party extension: ${manifest.display_name} (${id})`);
14961500 promises.push(updateExtension(id.replace('third-party', ''), true, autoUpdateTimeout));
14971501 }
14981502 }
14991503 await Promise.allSettled(promises);