Repository navigation
Description
Summary
When the -seeds file cannot be read, the run exits after the -o output file has been opened but before its cleanup is registered, so a hidden temporary file is left next to the output path and its handle is never closed.
Where
main_session.go:96(runWith):if !s.loadInputs() || !s.openOutputs() || !s.loadSeeds() {main_session.go:100-115: the deferreds.outFile.Close(s.anyDone)is only registered after all three succeedmain_session.go:401(loadSeeds)
Details
openOutputs calls output.CreateFile, which writes to a temporary file beside the target and only renames or removes it in Close. If loadSeeds then fails, runWith returns exitFailure without calling Close, so the temporary file stays on disk.
Steps to reproduce
printf 'www\n' > wl.txtsubenum -simulate -w wl.txt -o out.txt -seeds missing.json example.com- Exit code is 1 with
Error: reading -seeds file: ..., andls -Ashows a leftover.out.txt.<random>.tmp.
Impact
Stray hidden files accumulate next to the output path on every run with a bad -seeds path (for example in scheduled jobs). On Windows the open handle also keeps the file locked until the process exits. Low frequency, low severity.
Suggested fix
Read the seeds before opening outputs (loadInputs, loadSeeds, then openOutputs), or register the deferred close right after openOutputs succeeds. Add an e2e test that runs with a missing -seeds file and -o in a temp dir and asserts the directory has no leftover files.
Acceptance criteria
- A missing or unreadable
-seedsfile leaves no temporary file behind - Test covering it
Getting started
- Relevant files:
main_session.go,internal/output/file.go,main_e2e_test.go - How to run tests:
go test .
Filed by repo-audit/fix-issues at b1ee267. Severity: low. Effort: S. audit-key: bug|main_session.go|loadSeeds-before-outFile-close
Activity
TMHSDigital commentedon Nov 10, 2026
Fixed in 989741e:
runWithnow reads-seedsbefore opening the-ofile, so a failed seeds read has nothing to clean up. Verified with the newTestE2EBadSeedsLeavesNoTempFile, which failed before the change (leftover.out.txt.*.tmp, still locked on Windows) and passes after, plus the fullgo test ./....docs(changelog): unreleased fixes since v0.10.0 and version links (#231)