Repository navigation
Description
What happens
.github/scripts/fork-follow.sh line 51 makes its log folder like this and never removes it:
logs="${RUNNER_TEMP:-$(mktemp -d)}"On Actions RUNNER_TEMP is set, so nothing leaks there. Anywhere else (a developer or agent running the script tests) every call leaves one /tmp/tmp.XXXXXXXXXX folder holding fetch.log, schema-check.log, seam-check.log, rebase.log, triggers.log, paths and workflow.yml. The script has an ERR trap but no EXIT trap.
fork-follow.test.sh cleans its own $root with a trap, but it calls fork-follow.sh many times and those folders land outside $root. One run of the script tests leaves about 230 folders.
Measured on one dev machine
- 25,458
tmp.*folders in/tmpafter 7 days, about 4,000 a day, 0.7 GB. They are small, but/tmpgets slow to list. - Of the 2,071 made in the last day: 2,025 hold the fork-follow log names above, 18 hold an unpacked
t3-<version>-<platform>folder (second leak, below), 28 are empty (source not proven; likely a run that stopped before its first log).
Second, smaller leak
fork-release.sh, cmd_check_archives (line 251): work="$(mktemp -d)" is removed on line 267, but the two die calls between them exit first, so every refused archive leaves its unpacked folder behind. The tests exercise exactly those refusals.
Suggested fix
-
fork-follow.sh: keepRUNNER_TEMPas it is; when it is unset, own the folder and remove it on exit.if [[ -n "${RUNNER_TEMP:-}" ]]; then logs="$RUNNER_TEMP" else logs="$(mktemp -d "${TMPDIR:-/tmp}/fork-follow.XXXXXX")" trap 'rm -rf "$logs"' EXIT fi
Every use of
$logsis inside the script (the reports are written from the logs before it exits), so nothing reads the folder afterwards. -
fork-release.shcmd_check_archives: remove$workon every path, for example one folder for the whole function with anEXITtrap, orrm -rf "$work"before eachdie. -
Tests:
export TMPDIR="$root"at the top offork-follow.test.shandfork-release.test.sh, so anything a script still leaks lands in the folder the test already removes. Add one check to each that a call leaves no new entry in$TMPDIR(count before and after), for a passing and a refused run.
State questions
- Runs again: nothing accumulates; each call removes its own folder.
- Stops half-way (
set -e,die, a refusal): theEXITtrap still runs. Akill -9leaves one folder, now namedfork-follow.*, so a retention rule can match it by name instead of the catch-alltmp.*. - Old state: the folders already leaked are not touched by this fix; they need a one-off cleanup by age.
General vs project
General: these are fork tooling scripts with no project facts in them. Nothing project-specific is needed.
Activity
fork scripts: remove their own temp folders on every exit (#473) (#477)
fork scripts: remove their own temp folders on every exit (#473) (#477)
fork scripts: remove their own temp folders on every exit (#473) (#477)
fork scripts: remove their own temp folders on every exit (#473) (#477)
fork scripts: remove their own temp folders on every exit (#473) (#477)
fork scripts: remove their own temp folders on every exit (#473) (#477)
fork scripts: remove their own temp folders on every exit (#473) (#477)