Skip to content

fix: prevent locked scroll re-entry - #2760

Open
huytdps13400 wants to merge 1 commit into
gorhom:masterfrom
huytdps13400:fix/scroll-lock-reentrancy
Open

fix: prevent locked scroll re-entry#2760
huytdps13400 wants to merge 1 commit into
gorhom:masterfrom
huytdps13400:fix/scroll-lock-reentrancy

Conversation

@huytdps13400

Copy link
Copy Markdown

Motivation

Fixes #2737.

On iOS Fabric, scrollTo may synchronously emit another scroll or momentum-end event. While the scrollable remains LOCKED, the default handlers call scrollTo again on that same native stack until it overflows.

This change adds one shared-value re-entrancy guard around the three locked-state scrollTo call sites. The outer command and existing offset updates are preserved; only nested commands are skipped. The guard is released in finally so an error cannot leave the scrollable permanently locked.

Verification

  • yarn test — 2/2 regression tests pass (re-entry is bounded; lock is released after errors)
  • yarn typescript — pass
  • yarn biome check --error-on-warnings package.json src/hooks/executeWithLock.ts src/hooks/useScrollEventsHandlersDefault.ts tests/executeWithLock.test.cjs — pass
  • yarn build — pass for CommonJS, module, and TypeScript targets

Full yarn lint still reports the existing useOptionalChain warning in src/hooks/useBoundingClientRect.ts:54; that file is unchanged from master.

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.

[Bug]: scrollTo re-entrancy in the default scroll handlers overflows the native stack on iOS Fabric

1 participant