fix(webapp): pack parsing off the event loop; a server error isn't a sign-out (#1239) #1293
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/1239-pack-fetch-off-loop"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #1239. On prod (26 Oct), fetching both starter packs at once ran CPU-bound pack parsing on the event loop. Both uvicorn workers missed the 5 s healthcheck and were killed, and everyone looked signed out.
Backend (
app/reference/import_service.py):read_meta(in_prepare_systemand on the queued path) andread_pack(inimport_from_path) run inasyncio.to_thread.normalise's per-record walk is pure CPU: adapters parse lazily as they're iterated, and every record is sanitised. It's split into a sync_normalise_recordsrun in a thread, with the DB lookups kept in the async prelude. This goes beyond the issue's list, because without it most of the parsing still blocked the loop.source_record) runs in a thread too.import_pack/import_from_path. The Celery task gets the same change, which is harmless there.test_content_pack_off_loop.py: a slowread_packruns off the main thread, while a ticker coroutine keeps ticking during the admin import POST.Frontend:
useAuth: only a 401 from/api/memeans signed out. A 5xx or a network failure keepsloadingup and retries, backing off from 1 s to 15 s and cancelled on unmount.refreshUserclears the user only on a 401.retryingis exposed.AuthGuard's wait then says "Quest Board can't reach its server just now. Trying again…" instead of "Signing you in…" for as long as the server is down (added on review).retryingflag. AuthGuard tests cover both texts.Wording, held for the owner (Wording Review part i, i-003): the retry line above. Don't merge until it's decided.
Checked:
test_exif_orientation.py[WEBP]. It's unrelated and passed on rerun (222). It's a load flake, worth its own issue if it recurs.src/hooks+ AuthGuard: 40 passed. eslint: 0 errors.Not covered: the new off-loop test wasn't run against the unfixed code to prove it fails there.
export_pack's zip building is still CPU work on the loop, a smaller and separate case.🤖 Generated with Claude Code