activitywatch: Gap of Negative Duration could NOT be Fixed - AW Server stuck in loop without exiting

  • I am on the latest ActivityWatch version.
  • I have searched the issues of this repo and believe that this is not a duplicate.
  • OS name and version: Arch Linux x86_64
  • ActivityWatch version: v0.13.2

Describe the bug

Within one specific week I am getting:

 2025-01-07 06:06:55 [WARNING]: Gap was of negative duration but could be safely merged (-165.163s). This message will only show once per batch.  (aw_transform.flood:46)
 2025-01-07 06:06:55 [WARNING]: Gap was of negative duration and could NOT be safely merged (-330.409s). This warning will only show once per batch.  (aw_transform.flood:52)

the query will run out of time and the banner AxiosError: timeout of 90000ms exceeded. See dev console (F12) and/or server logs for more info. is displayed at the top of the webpage. However the activitywatch server will still continue to use 100% of one CPU core until manually stopped.

To Reproduce

I start the server image The server is running image I can change to the previous week, no problem image Note the cpu load on the right, the spike occurs when I change the week, but its okay, because the calculation is finished after some time. Now if I change to the week before that the CPU load does not decrease image At some time a timeout message is displayed and a warning in the logs image But even though the request is supposed to time out, the CPU usage stays at 100% image Pressing Ctrl C does not do anything image But sending SIGTERM works image image

Expected behavior

Just seeing the stats of that week

Documentation

Logs: aw-log-bug.log

Additional context

Maybe related to #239

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Comments: 20 (6 by maintainers)

Most upvoted comments

By the way, is there any way to restart the activitywatch server after it crashed? Running aw-qt & disown -a still seems to close activitywatch when I close the terminal window?

I don’t use aw-qt much. But since you are on linux you can set up a systemd service to run aw-server-rust with the restart=always option true. Chatgpt or Claude can help you figure it out.

I just double checked, yes, the aw-server-rust when checked out from the github repo, does indeed work without problems. This also still works when importing my own settings.

The latest version of the aw-server-rust does not have the same issue?

Keep it open. Might be useful if somebody else has the same issue. We’ll archive the repo if we finally ditch the python server.

On Thu, 16 Jan 2025, 00:01 Caspar, @.***> wrote:

So I dont know if I should close the issue with that, or if it is kept open. As far as I understand activity watch wants to switch to the rust server anyways at some point.

— Reply to this email directly, view it on GitHub https://github.com/ActivityWatch/activitywatch/issues/1125#issuecomment-2593925803, or unsubscribe https://github.com/notifications/unsubscribe-auth/AO6ENNIHDGXZOZ2Y4ZD2G3L2K3EA5AVCNFSM6AAAAABUW66GUSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKOJTHEZDKOBQGM . You are receiving this because you were mentioned.Message ID: @.***>

Yes, it is mentioned multiple times in the logs

[2025-01-13 10:53:23][INFO][rocket_cors::_]: Verifying origin: http://127.0.0.1:5666
[2025-01-13 10:53:23][INFO][rocket_cors::_]: Origin has an exact match
[2025-01-13 10:53:23][INFO][rocket::server]: POST /api/0/query/ application/json:
[2025-01-13 10:53:23][INFO][rocket::server::_]: Matched: (query) POST /api/0/query/ application/json
[2025-01-13 10:53:23][WARN][aw_transform::flood]: Gap was of negative duration (-PT1501.606Ss), but could be safely merged. This error will only show once per batch.
[2025-01-13 10:53:24][INFO][rocket::server::_]: Outcome: Success(200 OK)
[2025-01-13 10:53:24][DEBUG][rocket::server]: sending response: Response {
    status: 200,
    version: HTTP/1.1,
    headers: {
        "content-type": "application/json",
        "server": "Rocket",
        "x-frame-options": "SAMEORIGIN",
        "x-content-type-options": "nosniff",
        "permissions-policy": "interest-cohort=()",
        "access-control-allow-origin": "http://127.0.0.1:5666",
        "content-length": "1631",
    },
    body: Body(
        Streaming,
    ),
}
[2025-01-13 10:53:24][INFO][rocket::server::_]: Response succeeded.

however there it seems like everything could be safetly merged.

@0xbrayo As far as I can tell the issue does not occur in aw-server-rust : ) I cloned the repo, built the project, ran it in debugging mode using cargo and tested it by stepping through the last weeks.