Skip to content

[AI generated PR] Fix tab switching infinite loop when limitToCurrentWindow is true - #158

Open
lp-lima wants to merge 1 commit into
fwextensions:masterfrom
lp-lima:fix-tab-switching-infinite-loop
Open

[AI generated PR] Fix tab switching infinite loop when limitToCurrentWindow is true#158
lp-lima wants to merge 1 commit into
fwextensions:masterfrom
lp-lima:fix-tab-switching-infinite-loop

Conversation

@lp-lima

@lp-lima lp-lima commented Jul 26, 2026

Copy link
Copy Markdown

Disclaimer

I'm wholly ignorant on the code, the language, Chrome extensions and whatnot. I just liked the extension, asked the AI to fix this minor bug locally. When I saw it worked, I wanted to contribute back.

AI-generated PR description

This PR fixes a bug where rapidly navigating backwards through tabs with 'Limit recent tabs to the current browser window' enabled could cause the navigation index to double-decrement. If it missed the single exit condition due to this skipping, the recursive switchTabs function would fall into an infinite loop and crash the background service worker via a stack overflow.

Changes:

  • Adds a .catch() block to the main promise chain to gracefully recover if the background service worker ever hits a stack overflow.
  • Fixes the index tracker in switchTabs so it doesn't double-decrement when navigating backwards across windows.
  • Adds a hard counter (skipCount) fail-safe to gracefully exit if it iterates through the entire tab array without finding a matching tab.

@lp-lima lp-lima changed the title Fix tab switching infinite loop when limitToCurrentWindow is true [AI generated PR] Fix tab switching infinite loop when limitToCurrentWindow is true Jul 26, 2026
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