mirror of
https://github.com/tapframe/NuvioStreaming.git
synced 2026-01-11 20:10:25 +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);
|
||||
processStremioSource(type, stremioId, false);
|
||||
|
||||
// Add a delay before marking loading as complete to give Stremio addons more time
|
||||
setTimeout(() => {
|
||||
// Monitor scraper completion status instead of using fixed timeout
|
||||
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);
|
||||
}, 10000); // 10 second delay to allow streams to load
|
||||
setActiveFetchingScrapers([]);
|
||||
}, 30000);
|
||||
|
||||
} catch (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);
|
||||
processStremioSource('series', stremioEpisodeId, true);
|
||||
|
||||
// Add a delay before marking loading as complete to give Stremio addons more time
|
||||
setTimeout(() => {
|
||||
// Monitor scraper completion status instead of using fixed timeout
|
||||
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);
|
||||
}, 10000); // 10 second delay to allow streams to load
|
||||
setActiveFetchingScrapers([]);
|
||||
}, 30000);
|
||||
|
||||
} catch (error) {
|
||||
console.error('❌ [loadEpisodeStreams] Failed to load episode streams:', error);
|
||||
|
|
|
|||
|
|
@ -577,11 +577,7 @@ class LocalScraperService {
|
|||
URL_VALIDATION_ENABLED: urlValidationEnabled
|
||||
};
|
||||
|
||||
// Execute the scraper code with timeout
|
||||
const timeoutPromise = new Promise((_, reject) => {
|
||||
setTimeout(() => reject(new Error('Scraper execution timeout')), 60000); // 60 second timeout
|
||||
});
|
||||
|
||||
// Execute the scraper code without timeout
|
||||
const executionPromise = new Promise<LocalScraperResult[]>((resolve, reject) => {
|
||||
try {
|
||||
// Create function from code
|
||||
|
|
@ -614,7 +610,7 @@ class LocalScraperService {
|
|||
}
|
||||
});
|
||||
|
||||
return await Promise.race([executionPromise, timeoutPromise]) as LocalScraperResult[];
|
||||
return await executionPromise;
|
||||
|
||||
} catch (error) {
|
||||
logger.error('[LocalScraperService] Sandbox execution failed:', error);
|
||||
|
|
|
|||
Loading…
Reference in a new issue