activitywatch: TypeError: e.slice().map is not a function error after updating to version 0.13

  • 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: Ubuntu 22.04
  • ActivityWatch version: 0.13 (deb Installation)

Describe the bug

Since the new version (updated from 0.12.2 to 0.13) the WebUI does not work in Firefox anymore. There is an error

TypeError: e.slice().map is not a function. See dev console (F12) and/or server logs for more info.

image image

Opening the WebUI and everything is fine.

To Reproduce

Updating

While updating I found that you provide a deb package. I used the generic Linux zip file and started the binary from their.

I installed the deb file and started the application new from the /opt/activitywatch/aw-qt instead of $HOME/.local/bin/activitywatch/aw-qt

Expected behavior

  • Do not show the error, show the Activity screen

Documentation

I added some screenshots above, I hope this is fine.

Additional context

Maybe another bug or mistake I made, but I enable since the update and/or enable the rust server my categorization is gone. I don’t think this i related to the firefox bug.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 2
  • Comments: 15 (6 by maintainers)

Commits related to this issue

Most upvoted comments

[!WARNING] Important to note is that “Clearing cookies” also clears your categorization settings.

Clearing your cookies for localhost seems to fix this.

@ErikBjare just wanted to say thanks for developing this application. In recent weeks, I’ve been experimenting with several time-tracking services, such as RescueTime and ManicTime, and I have found ActivityWatch to be both the most user-friendly and the most powerful, due to the RegEx pattern matching.

I really wonder how many users will face this issue when upgrading…

@avi-cenna I edited in a warning in https://github.com/ActivityWatch/activitywatch/issues/1067#issuecomment-2148581034 so people will hopefully realize. Any proper solution would include correctly parsing the localStorage settings and migrating them to the server without any action by the user.

I realized the “e.slice().map is not a function” indicates that type of e has a slice() but not a map() on the resulting type. This probably means that e is a string and not an array as it should be, which indicates that localStorage.categories might not be parsed into JSON.


Analysis:

The issue was probably introduced in https://github.com/ActivityWatch/aw-webui/commit/1131f9b59b9291d6f6abe1d51b16a157adcdb815

When parsing we assume settings keys with a Data suffix are JSON-serialized: https://github.com/ActivityWatch/aw-webui/blame/05c25c98b172fcb72e2ae7cbf40be6bc77526c65/src/stores/settings.ts#L131-L132

But when writing we serialize all objects as JSON, so this may have been a bad assumption: https://github.com/ActivityWatch/aw-webui/blame/05c25c98b172fcb72e2ae7cbf40be6bc77526c65/src/stores/settings.ts#L183

This worked before the commit, since classes wasn’t read from localStorage in the settings.ts pinia store before (fixed in https://github.com/ActivityWatch/aw-webui/pull/572).

I would assume that it’s a problem with the migration to the server-side settings

I think I have a fix in https://github.com/ActivityWatch/aw-webui/pull/583, but I would appreciate a review/test from someone.

I confirm that clearing cookies resolved the issue. FWIW, here are the instructions to clear cookies for a single website in Chrome.

Screenshot 2024-06-05 at 10 53 02 AM