Skip to content

Commit fa1ed38

Browse files
committed
fix(core): clear #nextIntersection safeguard timeout on exit
Prevents a stale 3s timeout from prematurely resolving a subsequent #nextIntersection() call. Assisted-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 0466ae5 commit fa1ed38

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

core/pfe-core/controllers/scroll-spy-controller.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,10 +213,11 @@ export class ScrollSpyController implements ReactiveController {
213213
async #nextIntersection() {
214214
this.#intersected = false;
215215
// safeguard: break the loop after 3s even if no intersection fires
216-
setTimeout(() => this.#intersected = true, 3000);
216+
const timer = setTimeout(() => this.#intersected = true, 3000);
217217
while (!this.#intersected) {
218218
await new Promise(requestAnimationFrame);
219219
}
220+
clearTimeout(timer);
220221
}
221222

222223
async #onIo(entries: IntersectionObserverEntry[]) {

0 commit comments

Comments
 (0)