← Back to PRs

#13713: installers: clean temporary dirs after archive installs

by lawyered0 open 2026-02-10 22:55 View on GitHub →
stale
## Summary This PR closes a temp-directory leak in archive-based installer flows for both plugins and hooks. Repeated install/update operations could steadily grow `/tmp` with extracted archives and `npm pack` artifacts. ## User impact On systems that frequently install or update plugin/hook packs, leaked temporary directories can accumulate until disk pressure causes unrelated failures (including future installs and other runtime operations). This is a reliability issue that can become service-impacting under sustained usage. ## Root cause The installer code paths used `fs.mkdtemp(...)` but did not consistently pair them with `finally` cleanup. Early returns and error exits in those flows bypassed directory removal. ## What changed - `src/plugins/install.ts` already cleaned its temp dirs in the previous commit on this branch. - `src/hooks/install.ts` now uses guaranteed `try/finally` cleanup for: - archive extraction temp dirs (`openclaw-hook-*`) - npm pack temp dirs (`openclaw-hook-pack-*`) - Cleanup is best-effort (`fs.rm(..., { recursive: true, force: true }).catch(...)`) so it never masks install results. ## Tests - Existing plugin regression coverage remains on this branch: - `src/plugins/install.test.ts`: verifies no leaked `openclaw-plugin-*` temp dirs. - Added new hook regression coverage: - `src/hooks/install.test.ts`: verifies no leaked `openclaw-hook-*` temp dirs after archive install. - Validation run: - `pnpm test src/plugins/install.test.ts src/hooks/install.test.ts`

Most Similar PRs