Skip to content

fix(navigation): Prevent infinite recursion in nav feedback script - #441

Open
sentry[bot] wants to merge 1 commit into
mainfrom
seer/fix/navigation-recursion-guard
Open

fix(navigation): Prevent infinite recursion in nav feedback script#441
sentry[bot] wants to merge 1 commit into
mainfrom
seer/fix/navigation-recursion-guard

Conversation

@sentry

@sentry sentry Bot commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

This PR addresses a RangeError: Maximum call stack size exceeded that occurred during client-side navigation, particularly on Chrome Mobile iOS.

Root Cause:
The setPending and clearPending functions in src/layouts/layout.astro (within the inline navigation feedback script) modify DOM attributes (data-nav-pending) on document.body and anchor elements. On certain browsers (observed on Chrome Mobile iOS), these DOM mutations were found to re-trigger Astro's astro:before-preparation and astro:page-load navigation lifecycle events. Since the event listeners for these events call back into setPending(null) and clearPending respectively, an infinite mutual recursion loop was created, leading to a stack overflow.

Solution:
An isUpdating re-entrancy guard flag has been introduced within the IIFE scope of the navigation feedback script. Both setPending and clearPending now check this flag at their entry point. If isUpdating is true, the function immediately returns, preventing re-entrant calls from causing infinite recursion. The flag is set to true at the beginning of the function's execution and reset to false at the end.

Fixes BLOG-63

This PR was automatically generated by Sentry. You can adjust this setting at any time.

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.

0 participants