aw-client-js icon indicating copy to clipboard operation
aw-client-js copied to clipboard

String response causes TypeError in getEvents

Open itsfolf opened this issue 2 years ago • 1 comments

I am not entirely sure how, but it seems to be possible for the axios res.data to be a string, despite the content-type being correctly set to json, causing the snippet below to error with TypeError: n.forEach is not a function. This happens with both aw-server and aw-server-rust, and only in Firefox.

https://github.com/ActivityWatch/aw-client-js/blob/39868c71e48a23193aed77167894917ea423f812/src/aw-client.ts#L206-L211 https://github.com/ActivityWatch/aw-client-js/blob/39868c71e48a23193aed77167894917ea423f812/src/aw-client.ts#L99-L103

itsfolf avatar Jan 15 '24 14:01 itsfolf

After some further investigation, it seems like the error is caused by invalid json which axios decides to treat as a string, I am not able to share the full payload as it includes an entire day of private information, but I was able to narrow it down to the following section of events:

[{"id":21221,"timestamp":"2024-01-12T07:00:20.506Z","duration":0.0,"data":{"app":"Telegram.exe","title":"Furmeet Group @ Folf ᗢ�:04:40.705Z","duration":5.07,"data":{"app":"firefox.exe","title":"Commits · master · min / cshare · GitLab — Mozilla Firefox"}},{"id":22074,"timestamp":"2024-01-12T05:04:33.605Z","duration":6.083,"data":{"app":"firefox.exe","title":"min / cshare · GitLab — Mozilla Firefox"}},{"id":22075,"timestamp":"2024-01-12T05:04:31.576Z","duration":1.012999999,"data":{"app":"firefox.exe","title":"min · GitLab — Mozilla Firefox"}}]

Given this information, perhaps this issue is better well suited for aw-server or aw-server-rust, but as I'm not sure of the root cause I will leave it here for now.

itsfolf avatar Jan 15 '24 14:01 itsfolf