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

Match legacy wakatime-cli behavior around logging failed network connections #495

Closed
alanhamlett opened this issue Jul 6, 2021 · 3 comments
Assignees
Labels
bug Something isn't working p0 High Priority

Comments

@alanhamlett
Copy link
Member

alanhamlett commented Jul 6, 2021

Now that #385 is fixed, we're getting a lot of diagnostics logs from connection timeouts and other normal expected errors. For these "wontfix" errors, we should prevent sending diagnostics. The best way to do this is match the behavior of legacy wakatime-cli and only log errors when:

  • offline db disabled
  • saving the heartbeat to the offline db failed
  • debug mode enabled

For reference, the legacy Python logic around logging failed network requests:
https://github.com/wakatime/wakatime/blob/master/wakatime/api.py#L123

@github-actions github-actions bot added the triage label Jul 6, 2021
@alanhamlett alanhamlett added bug Something isn't working p1 Medium Priority and removed feature request triage labels Jul 6, 2021
@alanhamlett alanhamlett added p0 High Priority and removed p1 Medium Priority labels Jul 6, 2021
@alanhamlett
Copy link
Member Author

Example error messages:

{"caller":"/Users/runner/work/wakatime-cli/wakatime-cli/cmd/legacy/run.go:189","func":"runCmd","level":"error","message":"failed to run command: failed to send heartbeat(s): failed to send heartbeats via api client: failed making request to \"https://api.wakatime.com/api/v1/users/current/heartbeats.bulk\": Post \"https://api.wakatime.com/api/v1/users/current/heartbeats.bulk\": dial tcp 68.183.248.166:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.","now":"2021-07-06T14:37:51+08:00","version":"v1.18.9"}
{"caller":"/Users/runner/work/wakatime-cli/wakatime-cli/cmd/legacy/run.go:189","func":"runCmd","level":"error","message":"failed to run command: failed to send heartbeat(s): failed to send heartbeats via api client: failed making request to \"https://api.wakatime.com/api/v1/users/current/heartbeats.bulk\": Post \"https://api.wakatime.com/api/v1/users/current/heartbeats.bulk\": net/http: TLS handshake timeout","now":"2021-07-06T14:37:47+08:00","version":"v1.18.9"}
{"caller":"/Users/runner/work/wakatime-cli/wakatime-cli/cmd/legacy/run.go:189","func":"runCmd","level":"error","message":"failed to run command: failed to send heartbeat(s): failed to send heartbeats via api client: failed making request to \"https://api.wakatime.com/api/v1/users/current/heartbeats.bulk\": Post \"https://api.wakatime.com/api/v1/users/current/heartbeats.bulk\": dial tcp 68.183.248.166:443: i/o timeout (Client.Timeout exceeded while awaiting headers)","now":"2021-07-06T13:37:41+07:00","version":"v1.18.9"}
{"caller":"/Users/runner/work/wakatime-cli/wakatime-cli/cmd/legacy/run.go:189","func":"runCmd","level":"error","message":"failed to run command: failed to fetch today summary: failed fetching summaries from api: failed to make request to \"https://api.wakatime.com/api/v1/users/current/summaries\": Get \"https://api.wakatime.com/api/v1/users/current/summaries?end=2021-07-06&start=2021-07-06\": dial tcp 68.183.248.166:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.","now":"2021-07-06T14:37:44+08:00","version":"v1.18.9"}

@alanhamlett
Copy link
Member Author

Receiving the above diagnostics is a side-effect of the bug, where we shouldn't be logging network problems as errors unless debug mode is enabled or offline mode disabled.

@gandarez gandarez self-assigned this Jul 22, 2021
@gandarez
Copy link
Member

Closed via #502

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working p0 High Priority
Projects
None yet
Development

No branches or pull requests

2 participants