mirror of
https://github.com/ChuckBuilds/LEDMatrix.git
synced 2026-04-12 05:42:59 +00:00
fix(web): add fetch timeout to loadPluginsDirect fallback
Add AbortController with 10s timeout so a hanging fetch doesn't leave data-loaded set and block retries. Timer is cleared in both success and error paths. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -401,12 +401,15 @@
|
|||||||
if (content && !content.hasAttribute('data-loaded')) {
|
if (content && !content.hasAttribute('data-loaded')) {
|
||||||
content.setAttribute('data-loaded', 'true');
|
content.setAttribute('data-loaded', 'true');
|
||||||
console.log('Loading plugins directly via fetch (HTMX fallback)...');
|
console.log('Loading plugins directly via fetch (HTMX fallback)...');
|
||||||
fetch('/v3/partials/plugins')
|
const controller = new AbortController();
|
||||||
|
const timeout = setTimeout(() => controller.abort(), 10000);
|
||||||
|
fetch('/v3/partials/plugins', { signal: controller.signal })
|
||||||
.then(r => {
|
.then(r => {
|
||||||
if (!r.ok) throw new Error(r.status + ' ' + r.statusText);
|
if (!r.ok) throw new Error(r.status + ' ' + r.statusText);
|
||||||
return r.text();
|
return r.text();
|
||||||
})
|
})
|
||||||
.then(html => {
|
.then(html => {
|
||||||
|
clearTimeout(timeout);
|
||||||
content.innerHTML = html;
|
content.innerHTML = html;
|
||||||
// Trigger full initialization chain
|
// Trigger full initialization chain
|
||||||
if (window.pluginManager) {
|
if (window.pluginManager) {
|
||||||
@@ -418,6 +421,7 @@
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
|
clearTimeout(timeout);
|
||||||
console.error('Failed to load plugins:', err);
|
console.error('Failed to load plugins:', err);
|
||||||
content.removeAttribute('data-loaded');
|
content.removeAttribute('data-loaded');
|
||||||
content.innerHTML = '<div class="bg-red-50 border border-red-200 rounded-lg p-4"><p class="text-red-800">Failed to load Plugin Manager. Please refresh the page.</p></div>';
|
content.innerHTML = '<div class="bg-red-50 border border-red-200 rounded-lg p-4"><p class="text-red-800">Failed to load Plugin Manager. Please refresh the page.</p></div>';
|
||||||
|
|||||||
Reference in New Issue
Block a user