fix(missions): swap cache:no-store for query cache-buster (hang fix)
fetch(url, { cache: no-store }) was hanging forever through the
edge proxy on the mission API endpoints — requests never reached
postgres and the client-side loading state was stuck true, making
Refresh appear broken. Regressed in d42398d.
Switch to a per-request _t=Date.now() query param on GETs — same
cache-defeat effect, doesn't change fetch semantics.
This commit is contained in:
@@ -174,12 +174,14 @@ export interface CreateMissionRequest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function api<T>(path: string, init?: RequestInit): Promise<T> {
|
async function api<T>(path: string, init?: RequestInit): Promise<T> {
|
||||||
// Missions endpoints are mutable state (statuses transition every
|
// Missions endpoints are mutable state. We bypass browser cache
|
||||||
// few seconds) so we always bypass the browser cache. The old cache
|
// via a per-request `_t` query param rather than fetch's `cache:
|
||||||
// heuristic could serve a stale response for the manual Refresh
|
// "no-store"` mode, which appears to hang forever through the
|
||||||
// click, making it look like a no-op.
|
// edge proxy for reasons TBD.
|
||||||
const r = await fetch(path, {
|
const method = init?.method ?? "GET";
|
||||||
cache: "no-store",
|
const busted =
|
||||||
|
method === "GET" ? `${path}${path.includes("?") ? "&" : "?"}_t=${Date.now()}` : path;
|
||||||
|
const r = await fetch(busted, {
|
||||||
...init,
|
...init,
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
|
|||||||
Reference in New Issue
Block a user