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

[WARNING]: Inserting event that has a older timestamp than previous event! #16

Closed
dufferzafar opened this issue Mar 17, 2018 · 6 comments
Labels

Comments

@dufferzafar
Copy link

I'm running ActivityWatch from source (latest master repo) and using the Firefox extension.

I keep getting these warnings in the log, why could they be occurring?

2018-03-17 23:28:42 [WARNING]: Inserting event that has a older timestamp than previous event!
Previous:{'id': 758, 'duration': datetime.timedelta(0), 'timestamp': datetime.datetime(2018, 3, 17, 17, 58, 41, 956000, tzinfo=datetime.timezone.utc), 'data': {'title': '[REDACTED]', 'incognito': False, 'url': '[REDACTED]', 'audible': False}}
Inserted:{'id': 759, 'duration': datetime.timedelta(0), 'timestamp': datetime.datetime(2018, 3, 17, 17, 58, 41, 955000, tzinfo=datetime.timezone.utc), 'data': {'title': '[REDACTED]', 'incognito': False, 'url': '[REDACTED]', 'audible': False}}  (aw_datastore.datastore.Bucket:113)
@johan-bjareholt
Copy link
Member

Hm, odd. It's clear that one event is exactly 1ms earlier than the other one but it is received before it, that should be a programming error.
Not sure how this occurs, will look into it.

@johan-bjareholt
Copy link
Member

This part is likely the cause

https://github.com/ActivityWatch/aw-watcher-web/blob/master/app/eventPage.js#L49

// Any tab data has changed, finish previous event and insert new event
else if (JSON.stringify(last_heartbeat_data) != JSON.stringify(data)){
  //console.log("aw-watcher-web: Change");
  client.sendHeartbeat(new Date(now-1), last_heartbeat_data, heartbeat_pulsetime);
  client.sendHeartbeat(now, data, heartbeat_pulsetime);
  last_heartbeat_data = data;
  last_heartbeat_time = now;
}

Both the closing event and the new event are sent in the right order, but since the requests are asyncronous there's no guarantee which one will be received first from aw-server.

@dufferzafar
Copy link
Author

dufferzafar commented Mar 18, 2018 via email

@johan-bjareholt
Copy link
Member

We do not want this to happen due to how heartbeats works, the order they are inserted is important. We should fix it in the watcher itself somehow, just have to figure out what's the best way to do it.

@Otto-AA
Copy link
Contributor

Otto-AA commented Jun 17, 2018

Implemented in ActivityWatch/aw-client-js#7

@johan-bjareholt
Copy link
Member

Will be fixed by #19

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants