Skip to content

fix(extension): avoid same-url navigation timeout#377

Merged
jackwener merged 2 commits intojackwener:mainfrom
ayotme:fix/extension-same-url-timeout
Mar 24, 2026
Merged

fix(extension): avoid same-url navigation timeout#377
jackwener merged 2 commits intojackwener:mainfrom
ayotme:fix/extension-same-url-timeout

Conversation

@ayotme
Copy link
Copy Markdown
Contributor

@ayotme ayotme commented Mar 24, 2026

Summary

Fix a browser-bridge navigation bug where navigating to the same URL (or a canonicalized equivalent like:

  • https://example.com
  • https://example.com/

can wait for the full 15s timeout.

What changed

  • normalize URLs before comparison
  • fast-path navigation when the current tab is already at the target URL and fully loaded
  • treat navigation as complete when the tab reaches the target URL, instead of requiring a change from the previous
    URL
  • add a regression test for normalized same-URL navigation

Local impact

While reproducing this issue with browser-backed commands, I observed that same-URL navigation could add an
unnecessary ~15s delay before the next step ran.

After this fix, local verification showed:

  • warm runs dropping from ~18s+ to ~2.7s in the tested flow
  • cold runs also improving, while still including normal browser/session startup cost

Validation

  • npx tsc --noEmit
  • npm test
  • npm run test:adapter
  • extension regression test for background.ts
  • cd extension && npm run typecheck && npm run build

Note

While investigating this, I also noticed some commands may do redundant command-level navigation on top of framework
pre-navigation (for example bilibili/hot). I intentionally left adapter-level behavior changes out of this PR to
keep it focused on the browser bridge bug.

Copy link
Copy Markdown
Owner

@jackwener jackwener left a comment

Choose a reason for hiding this comment

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

Deep review from my side: the same-URL timeout fix is directionally right, but the original normalization was a bit too broad. I pushed a follow-up commit () that keeps the root slash canonicalization while preserving hash-route and non-root path distinctions, and added targeted extension tests for those cases.

Copy link
Copy Markdown
Owner

@jackwener jackwener left a comment

Choose a reason for hiding this comment

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

Deep review from my side: the same-URL timeout fix is directionally right, but the original normalization was a bit too broad. I pushed a follow-up commit (e8bb218) that keeps the root slash canonicalization while preserving hash-route and non-root path distinctions, and added targeted extension tests for those cases.

@jackwener
Copy link
Copy Markdown
Owner

Closing per maintainer request — too many formatting/style issues in the diff. Will redo the fix in a cleaner PR.

@jackwener jackwener closed this Mar 24, 2026
@jackwener jackwener merged commit b7ada0e into jackwener:main Mar 24, 2026
jackwener added a commit that referenced this pull request Mar 24, 2026
jackwener added a commit that referenced this pull request Mar 24, 2026
…ut (#380)

* Revert "fix(extension): avoid same-url navigation timeout (#377)"

This reverts commit b7ada0e.

* fix(extension): avoid same-url navigation timeout

- Add normalizeUrlForComparison for minimal URL canonicalization
  (root slash + default port only; preserves hash and non-root paths)
- Fast-path: skip navigation when tab is already at the target URL
- Rewrite wait logic with finish() pattern to prevent double-resolve
- Handle both same-URL and redirect scenarios in navigation listener
- Add regression tests for same-URL and hash-route distinction
@ayotme ayotme deleted the fix/extension-same-url-timeout branch March 25, 2026 00:57
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.

2 participants