Fix progress tracking synchronization issues
- Pre-generate sessionId on client side before API call to avoid race conditions - Add small delays in progress tracker to ensure EventSource connection is established - Improve logging and error handling in progress streaming - Add connection confirmation messages in EventSource stream - Fix TypeScript interface to include sessionId in AnalysisProgress This should resolve the lag between actual analysis progress and progress bar display.
This commit is contained in:
@@ -36,7 +36,12 @@ class ProgressTracker extends EventEmitter {
|
||||
}
|
||||
|
||||
this.sessions.set(sessionId, progress)
|
||||
this.emit(`progress:${sessionId}`, progress)
|
||||
|
||||
// Small delay to ensure EventSource connection is established before emitting
|
||||
setTimeout(() => {
|
||||
this.emit(`progress:${sessionId}`, progress)
|
||||
}, 100)
|
||||
|
||||
return progress
|
||||
}
|
||||
|
||||
@@ -77,7 +82,11 @@ class ProgressTracker extends EventEmitter {
|
||||
|
||||
this.sessions.set(sessionId, updatedProgress)
|
||||
console.log(`🔍 Emitting progress event for ${sessionId}, currentStep: ${updatedProgress.currentStep}`)
|
||||
this.emit(`progress:${sessionId}`, updatedProgress)
|
||||
|
||||
// Small delay to ensure proper event ordering and prevent race conditions
|
||||
setTimeout(() => {
|
||||
this.emit(`progress:${sessionId}`, updatedProgress)
|
||||
}, 50)
|
||||
}
|
||||
|
||||
updateTimeframeProgress(sessionId: string, current: number, total: number, currentTimeframe?: string): void {
|
||||
|
||||
Reference in New Issue
Block a user