* Schedule cleanup of completed process buffer after 30 minutes
(processId: string)
| 206 | * Schedule cleanup of completed process buffer after 30 minutes |
| 207 | */ |
| 208 | function scheduleCleanup(processId: string): void { |
| 209 | const proc = activeProcesses.get(processId) |
| 210 | if (!proc) return |
| 211 | |
| 212 | // Clear any existing cleanup timeout |
| 213 | if (proc.cleanupTimeoutId) { |
| 214 | clearTimeout(proc.cleanupTimeoutId) |
| 215 | } |
| 216 | |
| 217 | proc.cleanupTimeoutId = setTimeout(() => { |
| 218 | logger.info("[Process] Auto-cleanup triggered for process", JSON.stringify({ processId })) |
| 219 | const p = activeProcesses.get(processId) |
| 220 | if (p) { |
| 221 | // Clean up temp script if exists |
| 222 | if (p.tempScriptPath && fs.existsSync(p.tempScriptPath)) { |
| 223 | try { |
| 224 | fs.unlinkSync(p.tempScriptPath) |
| 225 | } catch (e) { |
| 226 | logger.warn("[Process] Failed to clean up temp script", JSON.stringify({ path: p.tempScriptPath, error: e })) |
| 227 | } |
| 228 | } |
| 229 | activeProcesses.delete(processId) |
| 230 | } |
| 231 | }, CLEANUP_DELAY_MS) |
| 232 | } |
| 233 | |
| 234 | /** |
| 235 | * Send output chunk to renderer |
no test coverage detected