Skip to content

Commit 69c44d9

Browse files
committed
fix(v2): guard per-card fetch cleanup by controller identity
An aborted per-card fetch's finally deleted the inFlightControllers entry unconditionally. If the position was cancelled and quickly re-entered the viewport, a replacement request could store a new controller under the same rom:${position} key before the aborted request reached finally; the unconditional delete then removed the new controller, so its response failed the ownership check and the card stayed a skeleton. Compare controller identity in both the success re-check and the finally delete (mirroring fetchInitialMetadata) so a request only ever clears its own entry. Generated-By: PostHog Code Task-Id: fe232494-3d20-4d83-9eaa-3ce341d4e7b5
1 parent 5790ff0 commit 69c44d9

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

frontend/src/v2/stores/galleryRoms.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -378,15 +378,22 @@ export default defineStore("v2GalleryRoms", {
378378
romId,
379379
signal: controller.signal,
380380
});
381-
// Re-check that the shell still wants this position — a fast
382-
// scroll past + cancel races against the response landing.
383-
if (!inFlightControllers.has(ctrlKey)) return;
381+
// Re-check that we're still the relevant request for this key — a
382+
// fast scroll-past + cancel + re-enter can replace our controller
383+
// with a newer one under the same key before we land. Identity
384+
// comparison keeps us from applying our stale response over it.
385+
if (inFlightControllers.get(ctrlKey) !== controller) return;
384386
this.byPosition.set(position, response.data);
385387
} catch (err) {
386388
if (axios.isCancel(err)) return;
387389
console.error("[v2GalleryRoms] rom fetch failed", position, romId, err);
388390
} finally {
389-
inFlightControllers.delete(ctrlKey);
391+
// Only clear our own entry — a replacement request may already own
392+
// the key (see the identity check above), and deleting it would
393+
// strand that request's response and leave the card a skeleton.
394+
if (inFlightControllers.get(ctrlKey) === controller) {
395+
inFlightControllers.delete(ctrlKey);
396+
}
390397
}
391398
},
392399

0 commit comments

Comments
 (0)