fix: Add missing analysis completion flag to enhanced screenshot API
- Add analysisCompletionFlag.startAnalysisCycle() at the beginning of screenshot API - Add analysisCompletionFlag.markAnalysisComplete() at the end of screenshot API - This ensures cleanup system can properly detect when analysis is complete - Fixes issue where cleanup was always skipped due to analysis appearing to still be running - Critical for preventing Chromium process accumulation during screenshot automation The enhanced screenshot API was missing completion flag logic that automation service has, causing cleanup to never trigger properly.
This commit is contained in:
@@ -59,6 +59,15 @@ export async function POST(request) {
|
||||
progressTracker.createSession(sessionId, initialSteps)
|
||||
console.log('🔍 Progress session created successfully')
|
||||
|
||||
// Mark the start of analysis cycle for cleanup system
|
||||
try {
|
||||
const { analysisCompletionFlag } = await import('../../../lib/analysis-completion-flag')
|
||||
analysisCompletionFlag.startAnalysisCycle(sessionId)
|
||||
console.log(`🔍 Analysis cycle started for session: ${sessionId}`)
|
||||
} catch (flagError) {
|
||||
console.error('Error starting analysis cycle:', flagError)
|
||||
}
|
||||
|
||||
// Prepare configuration for screenshot service
|
||||
const config = {
|
||||
symbol: symbol || 'BTCUSD',
|
||||
@@ -113,6 +122,15 @@ export async function POST(request) {
|
||||
message: `Successfully captured ${screenshots.length} screenshot(s)${analysis ? ' with AI analysis' : ''}`
|
||||
}
|
||||
|
||||
// Mark analysis as complete for cleanup system
|
||||
try {
|
||||
const { analysisCompletionFlag } = await import('../../../lib/analysis-completion-flag')
|
||||
analysisCompletionFlag.markAnalysisComplete(sessionId)
|
||||
console.log(`✅ Analysis marked as complete for session: ${sessionId}`)
|
||||
} catch (flagError) {
|
||||
console.error('Error marking analysis complete:', flagError)
|
||||
}
|
||||
|
||||
// Trigger post-analysis cleanup in development mode
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user