mirror of
https://github.com/tapframe/NuvioStreaming.git
synced 2026-04-20 16:22:04 +00:00
better error handling
This commit is contained in:
parent
f4b50f6dfb
commit
7bae3be975
2 changed files with 42 additions and 12 deletions
|
|
@ -858,10 +858,27 @@ export const useMetadata = ({ id, type, addonId }: UseMetadataProps): UseMetadat
|
||||||
console.log('🎬 [loadStreams] Using ID for Stremio addons:', stremioId);
|
console.log('🎬 [loadStreams] Using ID for Stremio addons:', stremioId);
|
||||||
processStremioSource(type, stremioId, false);
|
processStremioSource(type, stremioId, false);
|
||||||
|
|
||||||
// Add a delay before marking loading as complete to give Stremio addons more time
|
// Monitor scraper completion status instead of using fixed timeout
|
||||||
setTimeout(() => {
|
const checkScrapersCompletion = () => {
|
||||||
|
setScraperStatuses(currentStatuses => {
|
||||||
|
const allCompleted = currentStatuses.every(status => status.hasCompleted || status.error !== null);
|
||||||
|
if (allCompleted && currentStatuses.length > 0) {
|
||||||
|
setLoadingStreams(false);
|
||||||
|
setActiveFetchingScrapers([]);
|
||||||
|
}
|
||||||
|
return currentStatuses;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
// Check completion periodically
|
||||||
|
const completionInterval = setInterval(checkScrapersCompletion, 1000);
|
||||||
|
|
||||||
|
// Fallback timeout after 30 seconds
|
||||||
|
const fallbackTimeout = setTimeout(() => {
|
||||||
|
clearInterval(completionInterval);
|
||||||
setLoadingStreams(false);
|
setLoadingStreams(false);
|
||||||
}, 10000); // 10 second delay to allow streams to load
|
setActiveFetchingScrapers([]);
|
||||||
|
}, 30000);
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('❌ [loadStreams] Failed to load streams:', error);
|
console.error('❌ [loadStreams] Failed to load streams:', error);
|
||||||
|
|
@ -1010,10 +1027,27 @@ export const useMetadata = ({ id, type, addonId }: UseMetadataProps): UseMetadat
|
||||||
console.log('🎬 [loadEpisodeStreams] Using episode ID for Stremio addons:', stremioEpisodeId);
|
console.log('🎬 [loadEpisodeStreams] Using episode ID for Stremio addons:', stremioEpisodeId);
|
||||||
processStremioSource('series', stremioEpisodeId, true);
|
processStremioSource('series', stremioEpisodeId, true);
|
||||||
|
|
||||||
// Add a delay before marking loading as complete to give Stremio addons more time
|
// Monitor scraper completion status instead of using fixed timeout
|
||||||
setTimeout(() => {
|
const checkEpisodeScrapersCompletion = () => {
|
||||||
|
setScraperStatuses(currentStatuses => {
|
||||||
|
const allCompleted = currentStatuses.every(status => status.hasCompleted || status.error !== null);
|
||||||
|
if (allCompleted && currentStatuses.length > 0) {
|
||||||
|
setLoadingEpisodeStreams(false);
|
||||||
|
setActiveFetchingScrapers([]);
|
||||||
|
}
|
||||||
|
return currentStatuses;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
// Check completion periodically
|
||||||
|
const episodeCompletionInterval = setInterval(checkEpisodeScrapersCompletion, 1000);
|
||||||
|
|
||||||
|
// Fallback timeout after 30 seconds
|
||||||
|
const episodeFallbackTimeout = setTimeout(() => {
|
||||||
|
clearInterval(episodeCompletionInterval);
|
||||||
setLoadingEpisodeStreams(false);
|
setLoadingEpisodeStreams(false);
|
||||||
}, 10000); // 10 second delay to allow streams to load
|
setActiveFetchingScrapers([]);
|
||||||
|
}, 30000);
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('❌ [loadEpisodeStreams] Failed to load episode streams:', error);
|
console.error('❌ [loadEpisodeStreams] Failed to load episode streams:', error);
|
||||||
|
|
|
||||||
|
|
@ -577,11 +577,7 @@ class LocalScraperService {
|
||||||
URL_VALIDATION_ENABLED: urlValidationEnabled
|
URL_VALIDATION_ENABLED: urlValidationEnabled
|
||||||
};
|
};
|
||||||
|
|
||||||
// Execute the scraper code with timeout
|
// Execute the scraper code without timeout
|
||||||
const timeoutPromise = new Promise((_, reject) => {
|
|
||||||
setTimeout(() => reject(new Error('Scraper execution timeout')), 60000); // 60 second timeout
|
|
||||||
});
|
|
||||||
|
|
||||||
const executionPromise = new Promise<LocalScraperResult[]>((resolve, reject) => {
|
const executionPromise = new Promise<LocalScraperResult[]>((resolve, reject) => {
|
||||||
try {
|
try {
|
||||||
// Create function from code
|
// Create function from code
|
||||||
|
|
@ -614,7 +610,7 @@ class LocalScraperService {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return await Promise.race([executionPromise, timeoutPromise]) as LocalScraperResult[];
|
return await executionPromise;
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error('[LocalScraperService] Sandbox execution failed:', error);
|
logger.error('[LocalScraperService] Sandbox execution failed:', error);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue