web-archives icon indicating copy to clipboard operation
web-archives copied to clipboard

Receive "The page url is not valid" error notification when trying to access archive of website tab that is not loading.

Open kbailey4444 opened this issue 1 year ago • 1 comments

System

  • OS name: Debian
  • OS version: 12
  • Browser name: Firefox
  • Browser version: 130.0.1
  • Extension version: 6.1.1

Bug description

When trying to access the archive of the current tab when the website isn't loading, I receive the error notification stating "The page url is not valid". This mostly happens when trying to load a website that is experiencing an unexpected increase in traffic and is likely not returning a response.

Step 1. Try to access a website that is not loading. Step 2. Click the extension icon in the tool bar. Make sure "Tab" is selected vs "URL" Step 3. Click one of the engines, e.g. "Wayback Machine" or "Google". Step 4. Receive error notification "The page url is not valid".

Debugging

I did some light debugging of the code to try to understand why this happens. The relevant code appears to be in onActionPopupClick https://github.com/dessant/web-archives/blob/eb7bbdd94bdcb04cafa32bc8b3a66d80c62c45ae/src/background/main.js#L762

By logging the values of docUrl and tab.url in the function i get empty string for docUrl and "about:blank" for tab.url. Meaning that OnActionClick will be passed "about:blank" https://github.com/dessant/web-archives/blob/eb7bbdd94bdcb04cafa32bc8b3a66d80c62c45ae/src/background/main.js#L772

Eventually searchDocument will be passed "about:blank" https://github.com/dessant/web-archives/blob/eb7bbdd94bdcb04cafa32bc8b3a66d80c62c45ae/src/background/main.js#L466 Where it will call validateUrl on the string. Since "about:blank" isn't a valid url with http https or ftp protocols used, it shows the notification. https://github.com/dessant/web-archives/blob/eb7bbdd94bdcb04cafa32bc8b3a66d80c62c45ae/src/background/main.js#L468

How to Fix

So basically I expected the string in the address bar to be passed to the extension, but rather the url of the previously loaded page appears to be passed.

To fix this I guess it could be changed so that the url in the address bar could be passed. However that may break user's existing expectations in other contexts. Should the code just stay as is and the user be expected to enter the url in the extension when the page isn't loading?

Any ideas on how to approach fixing this?

kbailey4444 avatar Sep 19 '24 19:09 kbailey4444

I think this is a limitation in browsers, extensions cannot access the URL of the current tab if the page fails to load. One workaround would be to switch to the "URL" search mode in the toolbar popup and manually paste the inaccessible page URL there.

The only fix I can see now is to log all URL changes in tabs using a different extension API, though that is a bit wasteful.

dessant avatar May 27 '25 11:05 dessant