ZDDC/zddc/internal
ZDDC 1402864c4c fix(cache): track background revalidation goroutines; drain on shutdown + in tests
Root cause of the flaky cache tests (TestServeHTTP_DirectoryListingsCachedAsSidecar
and the other hit-path tests, ~1-in-many under parallel load): on a cache
hit, ServeHTTP launches `go c.revalidate(...)` / `go c.revalidateListing(...)`,
which write into the cache root (MkdirAll + CreateTemp + Rename). Those
goroutines outlive the request — and in tests, the test — so they race
t.TempDir's RemoveAll cleanup, recreating the dir or dropping a temp file
mid-removal. testing then reports "TempDir RemoveAll cleanup: ... directory
not empty" and marks the test failed (with a 0.00s body, no assertion line).
It only surfaced under the full parallel suite / -count because the timing
has to collide.

Fix: track these background goroutines in a sync.WaitGroup via a goBackground
helper, and expose Wait(). newTestCache registers t.Cleanup(c.Wait) — cleanups
fire LIFO and t.TempDir registered its RemoveAll first, so the drain runs
before it (upstream Close was registered earliest, so it runs last and stays
up while goroutines finish). runClient also calls cacheLayer.Wait() after
srv.Shutdown so in-flight sidecar writes complete on graceful shutdown rather
than being abandoned.

Verified: cache package at -count=200 reliably failed before, passes clean
after (0 failures, 0 cleanup errors); full `go test ./...` + vet green.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-21 16:21:37 -05:00
..
apps chore(embedded): cut v0.0.22-beta 2026-05-21 11:30:06 -05:00
archive refactor(archive): use shared zddc.ParseTransmittalFolder 2026-05-07 09:14:19 -05:00
auth feat(server): self-issued bearer tokens + --no-auth flag 2026-05-08 07:40:28 -05:00
cache fix(cache): track background revalidation goroutines; drain on shutdown + in tests 2026-05-21 16:21:37 -05:00
config docs+server: document the .zddc bootstrap config + warn at startup 2026-05-19 12:40:47 -05:00
convert refactor(convert): wrapper-in-image owns the sandbox; Go just exec's binaries 2026-05-19 07:47:58 -05:00
fs fix(listing): synthetic table.yaml/form.yaml verbs reflect actual authority 2026-05-21 13:23:12 -05:00
handler feat(form): ui:mirrorFrom — reflect a sibling field into a read-only field 2026-05-21 15:44:43 -05:00
jsonschema feat(forms): augment served schema with cascade field_codes + locks 2026-05-19 09:58:21 -05:00
listing feat(listing): per-entry verbs string for client-side capability gating 2026-05-21 08:14:25 -05:00
policy feat(listing): per-entry verbs string for client-side capability gating 2026-05-21 08:14:25 -05:00
tlsutil feat(server): TLS hardening per NIST SP 800-52 Rev. 2 + HSTS 2026-05-04 17:55:52 -05:00
zddc fix(records): validate folder_fields at load time + cache field-code patterns 2026-05-21 15:28:35 -05:00
zipfs feat(zddc): serve a .zip as a virtual directory (zipfs + dispatch intercept) 2026-05-12 12:17:47 -05:00