frontend: fetch City() concurrently with the page's primary API call #37
No reviewers
Labels
No labels
Compat/Breaking
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Status
Abandoned
Status
Blocked
Status
Need More Info
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: Jinemi/thermograph#37
Loading…
Reference in a new issue
No description provided.
Delete branch "frontend-concurrent-fetch"
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?
MonthPageandRecordsPageeach made two backend calls sequentially(
CityMonth/CityRecords, thenCity) where the second never depended onthe first's result — both are independent single-slug lookups. Waiting for
one full round trip before even starting the other was pure latency with
nothing to show for it.
fetchWithCitylaunches both concurrently via goroutines and aWaitGroup.Verified live, not just structurally
Built the binary, ran it against a stub content API with an injected
400ms delay on both endpoints, and timed cold requests on fresh server
instances (bypassing the response cache):
The two-call pages now cost the same as a single call, not the sum of two.
Error priority preserved exactly
If the primary call fails, its error wins even when
Cityalso fails orhasn't finished — matching the old sequential code (which never called
City()at all once primary had already failed).One real trade-off, called out in the code comment:
City()is nowalways launched, even on a request that's about to 404 from primary, so an
invalid slug costs one extra (wasted, cheap) backend lookup it previously
skipped. Worth it — a bad slug is the rare path, a good one is the common
path this speeds up.
Tests
combined-failure cases.
timing: the old sequential code would deadlock this test (and fail its
timeout), not just run it slower — a stronger guarantee than a flaky
wall-clock assertion.
-race -count=2.go testinside the image) passes.