Skip to content

Commit a9d17ab

Browse files
committed
fix(#78): add AbortController to SIS link fetch to prevent stale updates
1 parent 30a617f commit a9d17ab

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

  • codebenders-dashboard/app/students/[guid]

codebenders-dashboard/app/students/[guid]/page.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@ export default function StudentDetailPage() {
106106

107107
useEffect(() => {
108108
if (!guid) return
109-
fetch(`/api/students/${encodeURIComponent(guid)}/sis-link`)
109+
const controller = new AbortController()
110+
fetch(`/api/students/${encodeURIComponent(guid)}/sis-link`, { signal: controller.signal })
110111
.then(r => {
111112
if (r.status === 403) {
112113
setSisStatus("hidden")
@@ -130,7 +131,10 @@ export default function StudentDetailPage() {
130131
setSisStatus("unavailable")
131132
}
132133
})
133-
.catch(() => setSisStatus("hidden"))
134+
.catch(err => {
135+
if (err.name !== "AbortError") setSisStatus("hidden")
136+
})
137+
return () => controller.abort()
134138
}, [guid])
135139

136140
// ─── Loading skeleton ────────────────────────────────────────────────────

0 commit comments

Comments
 (0)