Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extension is no longer tracking time #291

Closed
fromage9747 opened this issue Nov 3, 2024 · 13 comments
Closed

Extension is no longer tracking time #291

fromage9747 opened this issue Nov 3, 2024 · 13 comments

Comments

@fromage9747
Copy link

Ever since the most recent update to the extension, it has stopped tracking time. I have tried removing it and configuring it all again, but the result is the same.

Are there any logs that I can look at to see why nothing is being logged? It worked well for months.

@fromage9747
Copy link
Author

Just had this error get spat out in my console from one of the sites its supposed to be tracking

image

Uncaught (in promise) Error: Extension context invalidated.
    at wakatimeScript.js:1:371252
    at wakatimeScript.js:1:371211

@ouuan
Copy link

ouuan commented Nov 9, 2024

I see "Cross-Origin Request Blocked" in the logs. I believe that 88cd994 caused the issue. That commit removed <all_urls> from permissions. <all_urls> was valid in manifest v2, but is now moved to host_permissions in manifest v3. So it is invalid as said in the commit on Chrome, but not on Firefox, which is still using manifest v2. Now on Firefox, the extension does not have permission to send cross-origin requests to the WakaTime server.

However, adding back <all_urls> would pose potential security risks. It would be better to only declare permissions for the WakaTime server. But in order to support custom servers, it should request permissions during runtime when the user sets the API URL in the settings.

By the way, I think we can use manifest v3 for Firefox to be consistent with Chrome.

@ouuan
Copy link

ouuan commented Nov 9, 2024

By the way, I think we can use manifest v3 for Firefox to be consistent with Chrome.

#161 was opened just 2 days after Firefox 109 with MV3 support was released. I guess that was the reason to keep using MV2 for Firefox. Now it makes sense to migrate to MV3 for Firefox.

ouuan added a commit to ouuan/browser-wakatime that referenced this issue Nov 9, 2024
1. Add permission for (api.)wakatime.com on Firefox.
2. Request permission for the API URL set by the user.
3. Restrict content script to run on meet.google.com only.
   This involves some strange logic about the host permissions:
   - If an origin is listed in `content_scripts.matches`, then the
     browser shows that the extension has permission to access data on
     that website. However, the background service worker cannot send
     cross-site requests to that URL.
   - If an origin is listed in both `content_scripts.matches` and
     `optional_host_permissions`, then the background service worker can
     send cross-site requests to that URL.
   So it's not possible to inject content scripts on all websites but
   conditionally ask for cross-site request permissions for specific
   websites only.
   Now it seems that the content script only works for meet.google.com.
   More websites may be added if needed later.
   An alternative solution is to use `scripting.registerContentScripts()`
   to dynamically register content script for websites, so that users
   can reject permissions on some websites and continue to use the
   extension. This could be implemented later.

This should fix wakatime#291
@fromage9747
Copy link
Author

@ouuan Is there any workaround to get this working for now? Surely I'm not the only one experiencing this issue?

@ouuan
Copy link

ouuan commented Nov 10, 2024

@ouuan Is there any workaround to get this working for now? Surely I'm not the only one experiencing this issue?

First, I want to make sure whether you are using the official WakaTime server (https://api.wakatime.com/) and whether you are using Chrome or Firefox. According to your screenshot, it seems that you are using Chrome. However, based on my experiments, the CORS request failure only happens for Firefox and custom WakaTime servers.

For further troubleshooting:

  • Check the "Site access: Allow this extension to read and change all your data on websites you visit" option on the extension details page.
  • Do you always see the "Extension context invalidated" error? I only see this error when I reinstall the extension.
  • Go to chrome://inspect/#service-workers and click "inspect" of jnbbnacmeggbgdjgaoojpmhdlkkpblgi. See the logs there.

@fromage9747
Copy link
Author

@ouuan Thank you for getting back to me.

  1. I am using https://api.wakatime.com/api/v1:

image

  1. I am using Google Chrome Version 130.0.6723.117 (Official Build) (64-bit)
  2. Permissions
    Read and change all your data on all websites

image

  1. "Extension context invalidated" It was something that I noticed shortly after logging this in GitHub and I had just reinstalled the extension as a last resort to try and get it working again.
  2. If I click on just the service worker there is nothing, it is blank:

image

  1. If I click on the other link under the service worker I get the below:

image

Is there anything else I can look at to find the issue?

@ouuan
Copy link

ouuan commented Nov 10, 2024

3. Permissions
Read and change all your data on all websites

What about the "Site Access" under "Permissions"? You can change the permissions there.

5. If I click on just the service worker there is nothing, it is blank:

Also check the Network tab. Switch between tabs and go back to the service worker inspector to see if heartbeats are sent.

@fromage9747
Copy link
Author

I have this:

image

Can't find anything regarding Site Access under:
chrome://settings/content/siteDetails?site=chrome-extension://jnbbnacmeggbgdjgaoojpmhdlkkpblgi

Checking the network tab whilst flipping through a few sites I get the below:

image

This is all being performed whilst using Chrome on Windows. I thought I should give it a try using Chrome on Mac and its the same result.

I also tried using Chrome in Incognito mode with only the Wakatime extension enabled to remove any doubt of a conflicting extension, and it's the same outcome.

@ouuan
Copy link

ouuan commented Nov 10, 2024

Try clicking the extension icon. It should send requests to the WakaTime server to get and display the stats if working normally:

image

@fromage9747
Copy link
Author

This always shows me my current time from when I work and track time through VSCode. And when I inspect the extension and then click on the icon I get the same network result as per my previous screenshot.

When I reinstalled the extension, I also removed all of my included sites and tested with one site to track thinking that maybe one of my configured sites was causing an issue but even with just using once site, no tracking came through. I tried with a few sites individually to get a good sample set of tests and none of them worked.

Investigating a bit further, in the previous version when it did work. When you added a new site you needed to add "@@" after the URL to track so that it came up in Wakatime under the category/name you wanted. I just checked now, and the example provided no longer includes the "@@" perhaps this is my problem?

@fromage9747
Copy link
Author

@ouuan Alright, it's tracking it now, but it's not logging it under the correct Project. Now that the "@@" functionality has been removed... I see that I have to add it under projects in order to get it to correctly log under the right project as it was logging it under a completely irrelevant project name.

Looks like there was no issue with the extension, just configuration changes that I was unaware of after the most recent update.

I just double-checked the GitHub page and there isn't any reference to this configuration.

Anyway, glad its working now.

Thanks for the help.

@ouuan
Copy link

ouuan commented Nov 10, 2024

Fine, so we are encountering different issues. Glad to see yours is now resolved. I think you can close this issue as this thread is now off-topic for my issue on Firefox.

@fromage9747
Copy link
Author

Good luck!

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 a pull request may close this issue.

2 participants