Skip to content

fix: cancel scroll completion checks on unmount - #509

Closed
JacquesLeupin wants to merge 1 commit into
LegendApp:mainfrom
JacquesLeupin:jleupin/fix-unmount-scroll-watchdog
Closed

fix: cancel scroll completion checks on unmount#509
JacquesLeupin wants to merge 1 commit into
LegendApp:mainfrom
JacquesLeupin:jleupin/fix-unmount-scroll-watchdog

Conversation

@JacquesLeupin

@JacquesLeupin JacquesLeupin commented Jul 22, 2026

Copy link
Copy Markdown

Summary

  • cancel the stored scroll-completion animation frame and fallback timeout when LegendList unmounts
  • cancel a pending completion frame before replacing it so rapid native scroll events cannot orphan an older callback
  • reuse the same cleanup when a new programmatic scroll supersedes pending completion work
  • clear both stored handles after cancellation, including valid handle 0

Root cause

checkFinishedScrollFallback stores its watchdog in timeoutCheckFinishedScrollFallback, outside the generic state.timeouts registry that unmount cleanup clears. The completion animation frame is stored separately as well. Both handles could therefore survive teardown and call back into an unmounted list.

checkFinishedScroll could also overwrite the stored animation-frame ID when multiple native scroll events arrived before the next frame. Coalescing completion checks to the latest frame prevents an older callback from becoming unreachable by cleanup.

This addresses the reproduced post-unmount watchdog failure in #508. #485 is complementary work for fallback re-arming during a live session.

Validation

  • pnpm dlx bun test __tests__/core/checkFinishedScroll.test.ts __tests__/core/scrollTo.test.ts __tests__/components/LegendList.props.test.tsx (67 passed)
  • pnpm dlx bun run tsc:src
  • pnpm dlx bun run lint:fix
  • pnpm dlx bun run lint
  • pnpm dlx bun test (1,514 passed)
  • pnpm dlx bun run build

@JacquesLeupin
JacquesLeupin marked this pull request as ready for review July 22, 2026 15:09

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 69f2175808

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/core/cancelScrollCompletionChecks.ts
The fallback watchdog and completion animation frame are stored outside the generic timer registry, so list cleanup could leave them pending and let callbacks run after teardown.

Share cancellation between scroll supersession and unmount, and cancel an existing completion frame before replacing it so rapid scroll events cannot orphan an older callback. Clear stored handles after cancellation and cover valid handle zero in regression tests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant