pauldub / activity-watch-mode

Emacs plugin for automatic time tracking and metrics generated from your programming activity.
https://activitywatch.net
70 stars 9 forks source link

Failiure to handle returning from bucket creation request correctly #5

Closed freemin7 closed 5 years ago

freemin7 commented 5 years ago

With fixes for #2 , #3 and work around for #4 in place the following error occurs if not bucket is created yet:

Debugger entered--Lisp error: (wrong-number-of-arguments ((t) (&allow-other-keys) (setq activity-watch-bucket-created t)) 8)
  (closure (t) (&allow-other-keys) (setq activity-watch-bucket-created t))(:data nil :symbol-status success :error-thrown nil :response #s(request-response :status-code 200 :history nil :data nil :error-thrown nil :symbol-status success :url "http://localhost:5600/api/0/buckets/aw-watcher-emacs_l191" :done-p nil :settings (:type "POST" :data "{\"hostname\":\"l191\",\"client\":\"emacs-activity-watch\",\"type\":\"app.editor.activity\"}" :headers (("Content-Type" . "application/json")) :success (closure (t) (&allow-other-keys) (setq activity-watch-bucket-created t)) :error #f(compiled-function (&rest args2) #<bytecode 0x497321>) :url "http://localhost:5600/api/0/buckets/aw-watcher-emacs_l191" :response #1) :-buffer #<killed buffer> :-raw-header "HTTP/1.0 200 OK\nContent-Type: application/json\nContent-Length: 3\nServer: Werkzeug/0.14.1 Python/3.6.3\nDate: Mon, 22 Apr 2019 13:40:54 GMT\n" :-timer nil :-backend curl :-tempfiles ("/tmp/emacs-requesthsdgUb")))
  apply((closure (t) (&allow-other-keys) (setq activity-watch-bucket-created t)) (:data nil :symbol-status success :error-thrown nil :response #s(request-response :status-code 200 :history nil :data nil :error-thrown nil :symbol-status success :url "http://localhost:5600/api/0/buckets/aw-watcher-emacs_l191" :done-p nil :settings (:type "POST" :data "{\"hostname\":\"l191\",\"client\":\"emacs-activity-watch\",\"type\":\"app.editor.activity\"}" :headers (("Content-Type" . "application/json")) :success (closure (t) (&allow-other-keys) (setq activity-watch-bucket-created t)) :error #f(compiled-function (&rest args2) #<bytecode 0x497321>) :url "http://localhost:5600/api/0/buckets/aw-watcher-emacs_l191" :response #2) :-buffer #<killed buffer> :-raw-header "HTTP/1.0 200 OK\nContent-Type: application/json\nContent-Length: 3\nServer: Werkzeug/0.14.1 Python/3.6.3\nDate: Mon, 22 Apr 2019 13:40:54 GMT\n" :-timer nil :-backend curl :-tempfiles ("/tmp/emacs-requesthsdgUb"))))
  apply(apply (closure (t) (&allow-other-keys) (setq activity-watch-bucket-created t)) (:data nil :symbol-status success :error-thrown nil :response #s(request-response :status-code 200 :history nil :data nil :error-thrown nil :symbol-status success :url "http://localhost:5600/api/0/buckets/aw-watcher-emacs_l191" :done-p nil :settings (:type "POST" :data "{\"hostname\":\"l191\",\"client\":\"emacs-activity-watch\",\"type\":\"app.editor.activity\"}" :headers (("Content-Type" . "application/json")) :success (closure (t) (&allow-other-keys) (setq activity-watch-bucket-created t)) :error #f(compiled-function (&rest args2) #<bytecode 0x497321>) :url "http://localhost:5600/api/0/buckets/aw-watcher-emacs_l191" :response #2) :-buffer #<killed buffer> :-raw-header "HTTP/1.0 200 OK\nContent-Type: application/json\nContent-Length: 3\nServer: Werkzeug/0.14.1 Python/3.6.3\nDate: Mon, 22 Apr 2019 13:40:54 GMT\n" :-timer nil :-backend curl :-tempfiles ("/tmp/emacs-requesthsdgUb"))))
  request--safe-apply((closure (t) (&allow-other-keys) (setq activity-watch-bucket-created t)) (:data nil :symbol-status success :error-thrown nil :response #s(request-response :status-code 200 :history nil :data nil :error-thrown nil :symbol-status success :url "http://localhost:5600/api/0/buckets/aw-watcher-emacs_l191" :done-p nil :settings (:type "POST" :data "{\"hostname\":\"l191\",\"client\":\"emacs-activity-watch\",\"type\":\"app.editor.activity\"}" :headers (("Content-Type" . "application/json")) :success (closure (t) (&allow-other-keys) (setq activity-watch-bucket-created t)) :error #f(compiled-function (&rest args2) #<bytecode 0x497321>) :url "http://localhost:5600/api/0/buckets/aw-watcher-emacs_l191" :response #2) :-buffer #<killed buffer> :-raw-header "HTTP/1.0 200 OK\nContent-Type: application/json\nContent-Length: 3\nServer: Werkzeug/0.14.1 Python/3.6.3\nDate: Mon, 22 Apr 2019 13:40:54 GMT\n" :-timer nil :-backend curl :-tempfiles ("/tmp/emacs-requesthsdgUb"))))
  request--callback(#<killed buffer> :type "POST" :data "{\"hostname\":\"l191\",\"client\":\"emacs-activity-watch\",\"type\":\"app.editor.activity\"}" :headers (("Content-Type" . "application/json")) :success (closure (t) (&allow-other-keys) (setq activity-watch-bucket-created t)) :error #f(compiled-function (&rest args2) #<bytecode 0x497321>) :url "http://localhost:5600/api/0/buckets/aw-watcher-emacs_l191" :response #s(request-response :status-code 200 :history nil :data nil :error-thrown nil :symbol-status success :url "http://localhost:5600/api/0/buckets/aw-watcher-emacs_l191" :done-p nil :settings (:type "POST" :data "{\"hostname\":\"l191\",\"client\":\"emacs-activity-watch\",\"type\":\"app.editor.activity\"}" :headers (("Content-Type" . "application/json")) :success (closure (t) (&allow-other-keys) (setq activity-watch-bucket-created t)) :error #f(compiled-function (&rest args2) #<bytecode 0x497321>) :url "http://localhost:5600/api/0/buckets/aw-watcher-emacs_l191" :response #1) :-buffer #<killed buffer> :-raw-header "HTTP/1.0 200 OK\nContent-Type: application/json\nContent-Length: 3\nServer: Werkzeug/0.14.1 Python/3.6.3\nDate: Mon, 22 Apr 2019 13:40:54 GMT\n" :-timer nil :-backend curl :-tempfiles ("/tmp/emacs-requesthsdgUb")))
  apply(request--callback #<killed buffer> (:type "POST" :data "{\"hostname\":\"l191\",\"client\":\"emacs-activity-watch\",\"type\":\"app.editor.activity\"}" :headers (("Content-Type" . "application/json")) :success (closure (t) (&allow-other-keys) (setq activity-watch-bucket-created t)) :error #f(compiled-function (&rest args2) #<bytecode 0x497321>) :url "http://localhost:5600/api/0/buckets/aw-watcher-emacs_l191" :response #s(request-response :status-code 200 :history nil :data nil :error-thrown nil :symbol-status success :url "http://localhost:5600/api/0/buckets/aw-watcher-emacs_l191" :done-p nil :settings #1 :-buffer #<killed buffer> :-raw-header "HTTP/1.0 200 OK\nContent-Type: application/json\nContent-Length: 3\nServer: Werkzeug/0.14.1 Python/3.6.3\nDate: Mon, 22 Apr 2019 13:40:54 GMT\n" :-timer nil :-backend curl :-tempfiles ("/tmp/emacs-requesthsdgUb"))))
  request--curl-callback(#<process request curl> "finished\n")

Furthermore a bucket is created in activity-watch. If emacs is restarted the following error and stack trace is encountered:

> Debugger entered--Lisp error: (wrong-number-of-arguments ((t) (&allow-other-keys) (setq activity-watch-bucket-created t)) 8)
>   (closure (t) (&allow-other-keys) (setq activity-watch-bucket-created t))(:data nil :symbol-status success :error-thrown nil :response #s(request-response :status-code 304 :history nil :data nil :error-thrown nil :symbol-status success :url "http://localhost:5600/api/0/buckets/aw-watcher-emacs_l191" :done-p nil :settings (:type "POST" :data "{\"hostname\":\"l191\",\"client\":\"emacs-activity-watch\",\"type\":\"app.editor.activity\"}" :headers (("Content-Type" . "application/json")) :success (closure (t) (&allow-other-keys) (setq activity-watch-bucket-created t)) :error #f(compiled-function (&rest args2) #<bytecode 0xce9e8d>) :url "http://localhost:5600/api/0/buckets/aw-watcher-emacs_l191" :response #1) :-buffer #<killed buffer> :-raw-header "HTTP/1.0 304 NOT MODIFIED\nServer: Werkzeug/0.14.1 Python/3.6.3\nDate: Mon, 22 Apr 2019 13:51:02 GMT\n" :-timer nil :-backend curl :-tempfiles ("/tmp/emacs-requestxo2xOb")))
>   apply((closure (t) (&allow-other-keys) (setq activity-watch-bucket-created t)) (:data nil :symbol-status success :error-thrown nil :response #s(request-response :status-code 304 :history nil :data nil :error-thrown nil :symbol-status success :url "http://localhost:5600/api/0/buckets/aw-watcher-emacs_l191" :done-p nil :settings (:type "POST" :data "{\"hostname\":\"l191\",\"client\":\"emacs-activity-watch\",\"type\":\"app.editor.activity\"}" :headers (("Content-Type" . "application/json")) :success (closure (t) (&allow-other-keys) (setq activity-watch-bucket-created t)) :error #f(compiled-function (&rest args2) #<bytecode 0xce9e8d>) :url "http://localhost:5600/api/0/buckets/aw-watcher-emacs_l191" :response #2) :-buffer #<killed buffer> :-raw-header "HTTP/1.0 304 NOT MODIFIED\nServer: Werkzeug/0.14.1 Python/3.6.3\nDate: Mon, 22 Apr 2019 13:51:02 GMT\n" :-timer nil :-backend curl :-tempfiles ("/tmp/emacs-requestxo2xOb"))))
>   apply(apply (closure (t) (&allow-other-keys) (setq activity-watch-bucket-created t)) (:data nil :symbol-status success :error-thrown nil :response #s(request-response :status-code 304 :history nil :data nil :error-thrown nil :symbol-status success :url "http://localhost:5600/api/0/buckets/aw-watcher-emacs_l191" :done-p nil :settings (:type "POST" :data "{\"hostname\":\"l191\",\"client\":\"emacs-activity-watch\",\"type\":\"app.editor.activity\"}" :headers (("Content-Type" . "application/json")) :success (closure (t) (&allow-other-keys) (setq activity-watch-bucket-created t)) :error #f(compiled-function (&rest args2) #<bytecode 0xce9e8d>) :url "http://localhost:5600/api/0/buckets/aw-watcher-emacs_l191" :response #2) :-buffer #<killed buffer> :-raw-header "HTTP/1.0 304 NOT MODIFIED\nServer: Werkzeug/0.14.1 Python/3.6.3\nDate: Mon, 22 Apr 2019 13:51:02 GMT\n" :-timer nil :-backend curl :-tempfiles ("/tmp/emacs-requestxo2xOb"))))
>   request--safe-apply((closure (t) (&allow-other-keys) (setq activity-watch-bucket-created t)) (:data nil :symbol-status success :error-thrown nil :response #s(request-response :status-code 304 :history nil :data nil :error-thrown nil :symbol-status success :url "http://localhost:5600/api/0/buckets/aw-watcher-emacs_l191" :done-p nil :settings (:type "POST" :data "{\"hostname\":\"l191\",\"client\":\"emacs-activity-watch\",\"type\":\"app.editor.activity\"}" :headers (("Content-Type" . "application/json")) :success (closure (t) (&allow-other-keys) (setq activity-watch-bucket-created t)) :error #f(compiled-function (&rest args2) #<bytecode 0xce9e8d>) :url "http://localhost:5600/api/0/buckets/aw-watcher-emacs_l191" :response #2) :-buffer #<killed buffer> :-raw-header "HTTP/1.0 304 NOT MODIFIED\nServer: Werkzeug/0.14.1 Python/3.6.3\nDate: Mon, 22 Apr 2019 13:51:02 GMT\n" :-timer nil :-backend curl :-tempfiles ("/tmp/emacs-requestxo2xOb"))))
>   request--callback(#<killed buffer> :type "POST" :data "{\"hostname\":\"l191\",\"client\":\"emacs-activity-watch\",\"type\":\"app.editor.activity\"}" :headers (("Content-Type" . "application/json")) :success (closure (t) (&allow-other-keys) (setq activity-watch-bucket-created t)) :error #f(compiled-function (&rest args2) #<bytecode 0xce9e8d>) :url "http://localhost:5600/api/0/buckets/aw-watcher-emacs_l191" :response #s(request-response :status-code 304 :history nil :data nil :error-thrown nil :symbol-status success :url "http://localhost:5600/api/0/buckets/aw-watcher-emacs_l191" :done-p nil :settings (:type "POST" :data "{\"hostname\":\"l191\",\"client\":\"emacs-activity-watch\",\"type\":\"app.editor.activity\"}" :headers (("Content-Type" . "application/json")) :success (closure (t) (&allow-other-keys) (setq activity-watch-bucket-created t)) :error #f(compiled-function (&rest args2) #<bytecode 0xce9e8d>) :url "http://localhost:5600/api/0/buckets/aw-watcher-emacs_l191" :response #1) :-buffer #<killed buffer> :-raw-header "HTTP/1.0 304 NOT MODIFIED\nServer: Werkzeug/0.14.1 Python/3.6.3\nDate: Mon, 22 Apr 2019 13:51:02 GMT\n" :-timer nil :-backend curl :-tempfiles ("/tmp/emacs-requestxo2xOb")))
>   apply(request--callback #<killed buffer> (:type "POST" :data "{\"hostname\":\"l191\",\"client\":\"emacs-activity-watch\",\"type\":\"app.editor.activity\"}" :headers (("Content-Type" . "application/json")) :success (closure (t) (&allow-other-keys) (setq activity-watch-bucket-created t)) :error #f(compiled-function (&rest args2) #<bytecode 0xce9e8d>) :url "http://localhost:5600/api/0/buckets/aw-watcher-emacs_l191" :response #s(request-response :status-code 304 :history nil :data nil :error-thrown nil :symbol-status success :url "http://localhost:5600/api/0/buckets/aw-watcher-emacs_l191" :done-p nil :settings #1 :-buffer #<killed buffer> :-raw-header "HTTP/1.0 304 NOT MODIFIED\nServer: Werkzeug/0.14.1 Python/3.6.3\nDate: Mon, 22 Apr 2019 13:51:02 GMT\n" :-timer nil :-backend curl :-tempfiles ("/tmp/emacs-requestxo2xOb"))))
>   request--curl-callback(#<process request curl> "finished\n")

Interpretation Code path depending on activity-watch-bucket-created being false has an error in processing the result of the request to the activity-watch server about creating . The error prevents activity-watch-bucket-created from being changed to t. But the bucket is succesfully created in activity watch. After a restart it tries to recreate the bucket and fails to handle the request return values correctly. The response is 304 not modified since no new bucket is created.

I have no idea how to fix that. Work around:

  1. Have debugger enabled
  2. press e in debugger when this error is hit
  3. enter (setq activity-watch-bucket-created t) to make it not hit the code path again
  4. press c to let the program continue

This workaround does not persist and has to be repeated after every emacs restart.

freemin7 commented 5 years ago

works for me now no idea what changed