← Back to PRs

#17630: Fix LINE media temp files accumulating in os.tmpdir

by Clawborn open 2026-02-16 01:24 View on GitHub →
commands agents stale size: S trusted-contributor
## Description `downloadLineMedia` writes received media to `os.tmpdir()` but never cleans up the files. On a busy LINE bot, this causes unbounded temp file growth until the OS reboots or tmpdir is manually purged. ## Fix Schedule a best-effort `unlink` 5 minutes after download — enough time for the media pipeline to process the file. The timer is `unref`'d so it doesn't keep the process alive. ## Tests Added `src/line/download-cleanup.test.ts` verifying: - Temp files are created with correct prefix - Cleanup removes the file - Cleanup handles non-existent files gracefully ## AI Transparency - **Assisted by**: OpenClaw Agent (Claude 3.5 Sonnet / Opus) - **Testing level**: Fully tested with new unit tests (`src/line/download-cleanup.test.ts`) - **Prompt strategy**: Self-correction loop based on codebase analysis <!-- greptile_comment --> <h3>Greptile Summary</h3> Added automatic cleanup of temporary LINE media files to prevent unbounded accumulation in `os.tmpdir()`. Files are scheduled for deletion 5 minutes after download using an unref'd timer that won't block process exit. The implementation addresses the core issue of temp file accumulation, but the previous comment about timing risks remains valid — the fixed 5-minute delay could delete files mid-processing if media understanding operations (vision models, audio transcription) exceed this window. <h3>Confidence Score: 3/5</h3> - Safe to merge with acceptable risk, but the timing issue noted in previous comments should be considered for follow-up - The cleanup mechanism is correctly implemented with proper error handling and unref'd timers. However, the fixed 5-minute delay introduces a race condition risk already identified in previous review threads. The PR solves the immediate problem (unbounded temp file growth) but may create intermittent failures under heavy load or slow processing. - No additional files require special attention beyond what was already flagged in previous threads <sub>Last reviewed commit: 61f490b</sub> <!-- greptile_other_comments_section --> <!-- /greptile_comment -->

Most Similar PRs