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