Improve video upload stability and error handling

Implement robust error handling and directory creation for video uploads, enhance file validation with MIME type checking, and adjust database sync timeout for improved reliability.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: 70557b10-8a46-4f62-9cec-2397b6c48e73
Replit-Commit-Checkpoint-Type: full_checkpoint
This commit is contained in:
sebastjanartic
2025-09-06 19:33:55 +00:00
parent b054a0c2d9
commit 92e74abb6d
2 changed files with 151 additions and 34 deletions
+12 -6
View File
@@ -166,15 +166,21 @@ class VideoSyncService {
try {
await this.syncVideos();
// Add timeout protection for database sync
// Add timeout protection for database sync with longer timeout
const syncTimeout = new Promise((_, reject) =>
setTimeout(() => reject(new Error('Database sync timeout after 30 seconds')), 30000)
setTimeout(() => reject(new Error('Database sync timeout after 60 seconds')), 60000)
);
await Promise.race([
this.syncVideosToDatabase(),
syncTimeout
]);
try {
await Promise.race([
this.syncVideosToDatabase(),
syncTimeout
]);
} catch (error) {
console.error('❌ Database sync failed with timeout:', error);
console.log('⚠️ Continuing with cached data only - videos will still be available');
// Don't throw the error, just log it and continue
}
this.startPeriodicSync();
console.log('✅ Video sync service initialized successfully');