Prune can race with an in-flight render of a replaced file #1

closed cmc opened this on 2026-09-26 00:28 UTC

Discussion

cmc 2026-09-26 00:28 UTC

When a source file changes while a request still holds the old library.Item, render.Prune (run after the rescan) can remove the old version directory while Renderer.generate is writing into it:

  • os.Rename fails with ENOENT → that request returns 500.
  • or MkdirAll recreates the old directory after the prune → orphan until the next rescan.
  • or ServeFile 404s after Get returned.

Self-healing on the next request. Possible fix: prune only version directories older than the previous snapshot, or skip directories with a .tmp-* file younger than a minute.

closed by cmc in commit 2893c158e9: Fix v1 follow-ups (!3)

2026-09-26 19:08 UTC