wakatime / vscode-wakatime

Visual Studio Code plugin for automatic time tracking and metrics generated from your programming activity.
https://wakatime.com/vs-code
BSD 3-Clause "New" or "Revised" License
1.24k stars 137 forks source link

WakaTime: working offline... coding activity will sync next time we are online #342

Closed ishowman closed 1 year ago

ishowman commented 1 year ago

I can visit any website normally, but wakatime in VSCode says it is offline and can't not work. I've used wakatime for serveral years, it's normal in the past year but not work from 2023.

alanhamlett commented 1 year ago

In your ~/.wakatime/wakatime.log file what's the error message. Make sure to find the error message not related to backoff, which is just client-side rate limiting and doesn't show the network error because it skips connecting.

ishowman commented 1 year ago

@alanhamlett Thanks for your reply.I search backoff in ~/.wakatime/wakatime.log file and found this:

{"caller":"cmd/run.go:301","file":"e:\\codes\\cute-labors\\sell\\2.ts","func":"cmd.runCmd","is_write":true,"level":"error","lineno":104,"message":"failed to run command: sending heartbeat(s) failed: rate limited: won't send heartbeat due to backoff","now":"2023-04-17T12:15:16+08:00","os/arch":"windows/amd64","plugin":"vscode/1.77.3 vscode-wakatime/24.0.10","time":1681704916.2992156,"version":"v1.73.0"}
{"caller":"cmd/run.go:301","file":"e:\\codes\\cute-labors\\sell\\index.ts","func":"cmd.runCmd","level":"error","lineno":17,"message":"failed to run command: sending heartbeat(s) failed: rate limited: won't send heartbeat due to backoff","now":"2023-04-17T12:15:28+08:00","os/arch":"windows/amd64","plugin":"vscode/1.77.3 vscode-wakatime/24.0.10","time":1681704928.126442,"version":"v1.73.0"}

omg, I can not get any idea from it.

alanhamlett commented 1 year ago

We need the message NOT related to backoff so please search for lines that don't contain backoff.

Larsundso commented 1 year ago

I'm running into the same issue. I've condensed it down to the 1 error per type and no backoff errors

{"caller":"cmd/run.go:301","func":"cmd.runCmd","level":"error","lineno":44,"message":"failed to run command: sending heartbeat(s) failed: invalid api key... find yours at wakatime.com/api-key. authentication failed at \"https://api.wakatime.com/api/v1/users/current/heartbeats.bulk\"","now":"2023-04-28T09:47:44+02:00","os/arch":"linux/amd64","plugin":"vscode/1.77.3 vscode-wakatime/24.0.10","time":1682668064.4836502,"version":"v1.73.0"}
{"caller":"cmd/run.go:301","func":"cmd.runCmd","level":"error","lineno":160,"message":"failed to run command: offline sync failed: failed to sync offline heartbeats: authentication failed at \"https://api.wakatime.com/api/v1/users/current/heartbeats.bulk\"","now":"2023-04-14T15:17:16+02:00","os/arch":"linux/amd64","plugin":"vscode/1.77.3 vscode-wakatime/24.0.9","time":1681478235.558978,"version":"v1.73.0"}
{"caller":"cmd/run.go:301","func":"cmd.runCmd","level":"error","message":"failed to run command: today fetch failed: failed fetching today from api: authentication failed at \"https://api.wakatime.com/api/v1/users/current/statusbar/today\". body: \"{\\\"error\\\":\\\"Unauthorized\\\"}\\n\"","now":"2023-04-14T15:41:50+02:00","os/arch":"linux/amd64","version":"v1.73.0"}

It says my API Key is invalid, though when I visit wakatime.com/api-key it exactly matches the one in ~/.wakatime.cfg

alanhamlett commented 1 year ago

@Larsundso try saving your api key from within vscode just to make sure, so it writes the api key to ~/.wakatime.cfg again. I checked our logs and I'm seeing the 401 Unauthorized error for your account yesterday but it looks like it started working again. Maybe you're using a different machine today?

Larsundso commented 1 year ago

Same machine but indeed did start working. I installed another version of wakatime, then updated it back to the current one. Also replaced the API key in VSCode with the same one from the website. One of those solved it.

Thank you :)

alanhamlett commented 1 year ago

@GruDev325 fixed your issue. Your code stats should sync up soon.

demptd13 commented 5 months ago

@GruDev325 fixed your issue. Your code stats should sync up soon.

Hello! I also have same erron in VS Code:

{"caller":"cmd/run.go:341","file":"c:\\Users\\Igor\\.wakatime\\wakatime.log","func":"cmd.runCmd","level":"error","lineno":1,"message":"failed to run command: sending heartbeat(s) failed: won't send heartbeat due to backoff without proxy","now":"2024-04-25T17:10:41+03:00","os/arch":"windows/amd64","plugin":"vscode/1.83.1 vscode-wakatime/24.5.0","time":1714054241.3759532,"version":"v1.90.0"}

How I can fix it?

BrenoFariasdaSilva commented 3 months ago

Hi there. I have the same problem. I've tried everything, such as:

  1. Enable debug mode.
  2. Delete the ~/.wakatime/wakatime-internal.cfg
  3. Uninstalll the IDE and Plugin.
  4. Generate a new API Key (and yes, I've updated it in the config file)
  5. Delete the entire dir rm -rf ~/.wakatime*
  6. Search for Issues similar to it.

I'm desperate on this, as i use wakatime to prove working hours for a university project and I've been without this working probably since mid April.

Also, I've never used any VPN or proxy. It does not work on any computer of mine, on any os that i use (Windows, Mac, Linux or even Raspberry) in any network (home or university).

Here is my wakatime.cfg file:


[settings]
api_key = waka_278... (yes, it it filled)
debug = true

Here is my wakatime-internal.cfg file:

[internal]
backoff_retries           = 5
backoff_at                = 2024-06-07T10:45:00-03:00
cli_version_last_accessed = 1717766769

Here is a short part of the long log file:

{"caller":"pkg/deps/deps.go:38","file":"/Users/brenofarias/.wakatime/wakatime.log","func":"heartbeat.initHandleOptions","level":"debug","lineno":1,"message":"execute dependency detection","now":"2024-06-07T10:33:49-03:00","os/arch":"darwin/arm64","plugin":"vscode/1.90.0 vscode-wakatime/24.5.0","time":1717767229.7594938,"version":"v1.90.0"}
{"caller":"pkg/project/project.go:143","file":"/Users/brenofarias/.wakatime/wakatime.log","func":"heartbeat.initHandleOptions","level":"debug","lineno":1,"message":"execute project detection for: /Users/brenofarias/.wakatime/wakatime.log","now":"2024-06-07T10:33:49-03:00","os/arch":"darwin/arm64","plugin":"vscode/1.90.0 vscode-wakatime/24.5.0","time":1717767229.7594938,"version":"v1.90.0"}
{"caller":"pkg/project/project.go:243","file":"/Users/brenofarias/.wakatime/wakatime.log","func":"project.Detect","level":"debug","lineno":1,"message":"execute project-file-detector","now":"2024-06-07T10:33:49-03:00","os/arch":"darwin/arm64","plugin":"vscode/1.90.0 vscode-wakatime/24.5.0","time":1717767229.7594938,"version":"v1.90.0"}
{"caller":"pkg/project/project.go:243","file":"/Users/brenofarias/.wakatime/wakatime.log","func":"project.Detect","level":"debug","lineno":1,"message":"execute project-map-detector","now":"2024-06-07T10:33:49-03:00","os/arch":"darwin/arm64","plugin":"vscode/1.90.0 vscode-wakatime/24.5.0","time":1717767229.7594938,"version":"v1.90.0"}
{"caller":"pkg/project/project.go:243","file":"/Users/brenofarias/.wakatime/wakatime.log","func":"project.Detect","level":"debug","lineno":1,"message":"execute project-file-detector","now":"2024-06-07T10:33:49-03:00","os/arch":"darwin/arm64","plugin":"vscode/1.90.0 vscode-wakatime/24.5.0","time":1717767229.7594938,"version":"v1.90.0"}
{"caller":"pkg/project/project.go:243","file":"/Users/brenofarias/.wakatime/wakatime.log","func":"project.Detect","level":"debug","lineno":1,"message":"execute project-map-detector","now":"2024-06-07T10:33:49-03:00","os/arch":"darwin/arm64","plugin":"vscode/1.90.0 vscode-wakatime/24.5.0","time":1717767229.7594938,"version":"v1.90.0"}
{"caller":"pkg/project/project.go:290","file":"/Users/brenofarias/.wakatime/wakatime.log","func":"project.DetectWithRevControl","level":"debug","lineno":1,"message":"execute git-detector","now":"2024-06-07T10:33:49-03:00","os/arch":"darwin/arm64","plugin":"vscode/1.90.0 vscode-wakatime/24.5.0","time":1717767229.7594938,"version":"v1.90.0"}
{"caller":"pkg/project/project.go:290","file":"/Users/brenofarias/.wakatime/wakatime.log","func":"project.DetectWithRevControl","level":"debug","lineno":1,"message":"execute mercurial-detector","now":"2024-06-07T10:33:49-03:00","os/arch":"darwin/arm64","plugin":"vscode/1.90.0 vscode-wakatime/24.5.0","time":1717767229.7594938,"version":"v1.90.0"}
{"caller":"pkg/project/project.go:290","file":"/Users/brenofarias/.wakatime/wakatime.log","func":"project.DetectWithRevControl","level":"debug","lineno":1,"message":"execute svn-detector","now":"2024-06-07T10:33:49-03:00","os/arch":"darwin/arm64","plugin":"vscode/1.90.0 vscode-wakatime/24.5.0","time":1717767229.7594938,"version":"v1.90.0"}
{"caller":"pkg/project/subversion.go:92","file":"/Users/brenofarias/.wakatime/wakatime.log","func":"project.findSvnBinary","level":"debug","lineno":1,"message":"failed while calling svn --version: exec: \"svn\": executable file not found in $PATH","now":"2024-06-07T10:33:49-03:00","os/arch":"darwin/arm64","plugin":"vscode/1.90.0 vscode-wakatime/24.5.0","time":1717767229.7594938,"version":"v1.90.0"}
{"caller":"pkg/project/subversion.go:92","file":"/Users/brenofarias/.wakatime/wakatime.log","func":"project.findSvnBinary","level":"debug","lineno":1,"message":"failed while calling /usr/bin/svn --version: fork/exec /usr/bin/svn: no such file or directory","now":"2024-06-07T10:33:49-03:00","os/arch":"darwin/arm64","plugin":"vscode/1.90.0 vscode-wakatime/24.5.0","time":1717767229.7594938,"version":"v1.90.0"}
{"caller":"pkg/project/subversion.go:92","file":"/Users/brenofarias/.wakatime/wakatime.log","func":"project.findSvnBinary","level":"debug","lineno":1,"message":"failed while calling /usr/local/bin/svn --version: fork/exec /usr/local/bin/svn: no such file or directory","now":"2024-06-07T10:33:49-03:00","os/arch":"darwin/arm64","plugin":"vscode/1.90.0 vscode-wakatime/24.5.0","time":1717767229.7594938,"version":"v1.90.0"}
{"caller":"pkg/project/subversion.go:23","file":"/Users/brenofarias/.wakatime/wakatime.log","func":"project.Subversion","level":"debug","lineno":1,"message":"svn binary not found","now":"2024-06-07T10:33:49-03:00","os/arch":"darwin/arm64","plugin":"vscode/1.90.0 vscode-wakatime/24.5.0","time":1717767229.7594938,"version":"v1.90.0"}
{"caller":"pkg/project/project.go:290","file":"/Users/brenofarias/.wakatime/wakatime.log","func":"project.DetectWithRevControl","level":"debug","lineno":1,"message":"execute tfvc-detector","now":"2024-06-07T10:33:49-03:00","os/arch":"darwin/arm64","plugin":"vscode/1.90.0 vscode-wakatime/24.5.0","time":1717767229.7594938,"version":"v1.90.0"}
{"caller":"pkg/project/project.go:290","file":"/Users/brenofarias/.wakatime/wakatime.log","func":"project.DetectWithRevControl","level":"debug","lineno":1,"message":"execute git-detector","now":"2024-06-07T10:33:49-03:00","os/arch":"darwin/arm64","plugin":"vscode/1.90.0 vscode-wakatime/24.5.0","time":1717767229.7594938,"version":"v1.90.0"}
{"caller":"pkg/project/project.go:290","file":"/Users/brenofarias/.wakatime/wakatime.log","func":"project.DetectWithRevControl","level":"debug","lineno":1,"message":"execute mercurial-detector","now":"2024-06-07T10:33:49-03:00","os/arch":"darwin/arm64","plugin":"vscode/1.90.0 vscode-wakatime/24.5.0","time":1717767229.7594938,"version":"v1.90.0"}
{"caller":"pkg/project/project.go:290","file":"/Users/brenofarias/.wakatime/wakatime.log","func":"project.DetectWithRevControl","level":"debug","lineno":1,"message":"execute svn-detector","now":"2024-06-07T10:33:49-03:00","os/arch":"darwin/arm64","plugin":"vscode/1.90.0 vscode-wakatime/24.5.0","time":1717767229.7594938,"version":"v1.90.0"}
{"caller":"pkg/project/subversion.go:92","file":"/Users/brenofarias/.wakatime/wakatime.log","func":"project.findSvnBinary","level":"debug","lineno":1,"message":"failed while calling svn --version: exec: \"svn\": executable file not found in $PATH","now":"2024-06-07T10:33:49-03:00","os/arch":"darwin/arm64","plugin":"vscode/1.90.0 vscode-wakatime/24.5.0","time":1717767229.7594938,"version":"v1.90.0"}
{"caller":"pkg/project/subversion.go:92","file":"/Users/brenofarias/.wakatime/wakatime.log","func":"project.findSvnBinary","level":"debug","lineno":1,"message":"failed while calling /usr/bin/svn --version: fork/exec /usr/bin/svn: no such file or directory","now":"2024-06-07T10:33:49-03:00","os/arch":"darwin/arm64","plugin":"vscode/1.90.0 vscode-wakatime/24.5.0","time":1717767229.7594938,"version":"v1.90.0"}
{"caller":"pkg/project/subversion.go:92","file":"/Users/brenofarias/.wakatime/wakatime.log","func":"project.findSvnBinary","level":"debug","lineno":1,"message":"failed while calling /usr/local/bin/svn --version: fork/exec /usr/local/bin/svn: no such file or directory","now":"2024-06-07T10:33:49-03:00","os/arch":"darwin/arm64","plugin":"vscode/1.90.0 vscode-wakatime/24.5.0","time":1717767229.7594938,"version":"v1.90.0"}
{"caller":"pkg/project/subversion.go:23","file":"/Users/brenofarias/.wakatime/wakatime.log","func":"project.Subversion","level":"debug","lineno":1,"message":"svn binary not found","now":"2024-06-07T10:33:49-03:00","os/arch":"darwin/arm64","plugin":"vscode/1.90.0 vscode-wakatime/24.5.0","time":1717767229.7594938,"version":"v1.90.0"}
{"caller":"pkg/project/project.go:290","file":"/Users/brenofarias/.wakatime/wakatime.log","func":"project.DetectWithRevControl","level":"debug","lineno":1,"message":"execute tfvc-detector","now":"2024-06-07T10:33:49-03:00","os/arch":"darwin/arm64","plugin":"vscode/1.90.0 vscode-wakatime/24.5.0","time":1717767229.7594938,"version":"v1.90.0"}
{"caller":"pkg/project/filter.go:23","file":"/Users/brenofarias/.wakatime/wakatime.log","func":"heartbeat.initHandleOptions","level":"debug","lineno":1,"message":"execute project filtering","now":"2024-06-07T10:33:49-03:00","os/arch":"darwin/arm64","plugin":"vscode/1.90.0 vscode-wakatime/24.5.0","time":1717767229.7594938,"version":"v1.90.0"}
{"caller":"pkg/heartbeat/sanitize.go:30","file":"/Users/brenofarias/.wakatime/wakatime.log","func":"heartbeat.initHandleOptions","level":"debug","lineno":1,"message":"execute heartbeat sanitization","now":"2024-06-07T10:33:49-03:00","os/arch":"darwin/arm64","plugin":"vscode/1.90.0 vscode-wakatime/24.5.0","time":1717767229.7594938,"version":"v1.90.0"}
{"caller":"pkg/remote/remote.go:122","file":"/Users/brenofarias/.wakatime/wakatime.log","func":"heartbeat.initHandleOptions","level":"debug","lineno":1,"message":"execute remote cleanup","now":"2024-06-07T10:33:49-03:00","os/arch":"darwin/arm64","plugin":"vscode/1.90.0 vscode-wakatime/24.5.0","time":1717767229.7594938,"version":"v1.90.0"}
{"caller":"pkg/offline/offline.go:55","file":"/Users/brenofarias/.wakatime/wakatime.log","func":"heartbeat.SendHeartbeats","level":"debug","lineno":1,"message":"execute offline queue with file /Users/brenofarias/.wakatime.bdb","now":"2024-06-07T10:33:49-03:00","os/arch":"darwin/arm64","plugin":"vscode/1.90.0 vscode-wakatime/24.5.0","time":1717767229.7594938,"version":"v1.90.0"}
{"caller":"pkg/backoff/backoff.go:43","file":"/Users/brenofarias/.wakatime/wakatime.log","func":"heartbeat.SendHeartbeats","level":"debug","lineno":1,"message":"execute heartbeat backoff algorithm","now":"2024-06-07T10:33:49-03:00","os/arch":"darwin/arm64","plugin":"vscode/1.90.0 vscode-wakatime/24.5.0","time":1717767229.7594938,"version":"v1.90.0"}
{"caller":"pkg/backoff/backoff.go:102","file":"/Users/brenofarias/.wakatime/wakatime.log","func":"backoff.shouldBackoff","level":"debug","lineno":1,"message":"exponential backoff tried 4 times since 2024-06-07T10:32:58-03:00, will retry again after 2024-06-07T10:37:49-03:00","now":"2024-06-07T10:33:49-03:00","os/arch":"darwin/arm64","plugin":"vscode/1.90.0 vscode-wakatime/24.5.0","time":1717767229.7594938,"version":"v1.90.0"}
{"caller":"pkg/offline/offline.go:65","file":"/Users/brenofarias/.wakatime/wakatime.log","func":"heartbeat.SendHeartbeats","level":"debug","lineno":1,"message":"pushing 1 heartbeat(s) to queue due to error","now":"2024-06-07T10:33:49-03:00","os/arch":"darwin/arm64","plugin":"vscode/1.90.0 vscode-wakatime/24.5.0","time":1717767229.7594938,"version":"v1.90.0"}
{"caller":"cmd/run.go:341","file":"/Users/brenofarias/.wakatime/wakatime.log","func":"cmd.runCmd","level":"error","lineno":1,"message":"failed to run command: sending heartbeat(s) failed: won't send heartbeat due to backoff without proxy","now":"2024-06-07T10:33:49-03:00","os/arch":"darwin/arm64","plugin":"vscode/1.90.0 vscode-wakatime/24.5.0","time":1717767229.7594938,"version":"v1.90.0"}

So, the main message is "failed to run command: sending heartbeat(s) failed: won't send heartbeat due to backoff without proxy"

Please @alanhamlett or anyone help me ASAP!

BrenoFariasdaSilva commented 3 months ago

Also @alanhamlett, I've used Wakatime on JetBrains IntelliJ, but my main tool used is Visual Studio Code and it does not work anywhere since April so I can't provide the working hours report for my university project.