Add timeout to extensions auto-update
| @@ -976,11 +976,14 @@ async function onUpdateClick() { | ||
| 976 | 976 | * Updates a third-party extension via the API. |
| 977 | 977 | * @param {string} extensionName Extension folder name |
| 978 | 978 | * @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. | |
| 979 | 980 | */ |
| 980 | 981 | async function updateExtension(extensionName, quiet, timeout = null) { |
| 981 | 982 | try { |
| 983 | + const signal = timeout ? AbortSignal.timeout(timeout) : undefined; | |
| 982 | 984 | const response = await fetch('/api/extensions/update', { |
| 983 | 985 | method: 'POST', |
| 986 | + signal: signal, | |
| 984 | 987 | headers: getRequestHeaders(), |
| 985 | 988 | body: JSON.stringify({ |
| 986 | 989 | extensionName, |
| @@ -1009,7 +1012,7 @@ async function updateExtension(extensionName, quiet) { | ||
| 1009 | 1012 | toastr.success(t`Extension ${extensionName} updated to ${data.shortCommitHash}`, t`Reload the page to apply updates`); |
| 1010 | 1013 | } |
| 1011 | 1014 | } catch (error) { |
| 1012 | 1015 | console.error('ErrorExtension update error:', error); |
| 1013 | 1016 | } |
| 1014 | 1017 | } |
| 1015 | 1018 | |
| @@ -1480,6 +1483,7 @@ async function autoUpdateExtensions(forceAll) { | ||
| 1480 | 1483 | const banner = toastr.info(t`Auto-updating extensions. This may take several minutes.`, t`Please wait...`, { timeOut: 10000, extendedTimeOut: 10000 }); |
| 1481 | 1484 | const isCurrentUserAdmin = isAdmin(); |
| 1482 | 1485 | const promises = []; |
| 1486 | + const autoUpdateTimeout = 60 * 1000; | |
| 1483 | 1487 | for (const [id, manifest] of Object.entries(manifests)) { |
| 1484 | 1488 | const isDisabled = extension_settings.disabledExtensions.includes(id); |
| 1485 | 1489 | if (!forceAll && isDisabled) { |
| @@ -1493,7 +1497,7 @@ async function autoUpdateExtensions(forceAll) { | ||
| 1493 | 1497 | } |
| 1494 | 1498 | if ((forceAll || manifest.auto_update) && id.startsWith('third-party')) { |
| 1495 | 1499 | console.debug(`Auto-updating 3rd-party extension: ${manifest.display_name} (${id})`); |
| 1496 | 1500 | promises.push(updateExtension(id.replace('third-party', ''), true, autoUpdateTimeout)); |
| 1497 | 1501 | } |
| 1498 | 1502 | } |
| 1499 | 1503 | await Promise.allSettled(promises); |