#13713: installers: clean temporary dirs after archive installs
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
#19021: fix(hooks): reject path traversal in hook pack manifest entries dur...
by moxunjinmu · 2026-02-17
66.6%
#21039: Fix npm-spec plugin installs when npm pack output is empty
by graysurf · 2026-02-19
65.5%
#19449: fix: preserve .env during package/plugin updates
by Sid-V5 · 2026-02-17
64.7%
#13254: fix: harden archive extraction and plugin update rollback
by lawyered0 · 2026-02-10
64.3%
#11339: fix: resolve bundled hooks path on npm global install
by matthewpoe · 2026-02-07
64.2%
#16960: perf: skip cache-busting for bundled hooks, use mtime for workspace...
by mudrii · 2026-02-15
63.3%
#8073: fix(plugins): add --ignore-scripts to npm install
by yubrew · 2026-02-03
63.0%
#11817: fix(build): compile bundled hook handlers into dist
by AnonO6 · 2026-02-08
62.5%
#20424: Fix plugin extension path traversal in discovery/install
by markmusson · 2026-02-18
62.3%
#11432: fix(security): add --ignore-scripts to npm install in hook and plug...
by coygeek · 2026-02-07
61.8%