aw-watcher-vim
aw-watcher-vim copied to clipboard
Can't start watcher, weird channel errors? Data is 000
I finally decided to activitywatch after only knowing about this project for 4 years.
I installed this plugin and needed to copy some of the configuration to my vimrc. Spoiler alert: I did this: let g:aw_apiurl_host = 127.0.0.1.
Fast forward two hours of me learning lots about the rest API of aw-server, jobs and vim channels, trying to debug why curl -s http://127001/api/0/buckets/<hostname>/ wasn't working only to realise if you actually put let g:aw_apiurl_host = 127.0.0.1 into your vimrc then you're gonna have a BAD time. 127.0.0.1 actually concatenates that into 127001 and doesn't throw an error like how I would it expect it to do. So that's a learning.
My own debug logs of this, the "channel data" is somehow 000?

Not sure what can be done with this, I tried to add some validation:
function! AWStart()
" :h types here
if type(s:apiurl_host) != 1
echoerr "g:apiurl_host must be a string!"
return
endif
if type(s:apiurl_port) != 0
echoerr "g:apiurl_host must be a number!"
return
endif
call s:CreateBucket()
endfunc
But since it's a string it passed my ad-hoc validation.
Naturally, I can blame the documentation: he said sarcastically, please don't hurt me
Not sure what to make of this issue, but it hopefully makes someone that is having the same issue that might be searching github issues to find me in 2021 writing a post mortem 3 minutes to 1 am at a rainy wednesday night/morning.
Feel free to do whatever to this issue.
I also have this problem but haven't set the g:aw_apiurl_host=127.0.0.1 my vimrc (checked with grep) so how do we fix it?
I have this issue as well no matter host/port/timeout set or not:
Error detected while processing function HTTPPostOnExitVim[4]..HTTPPostOnExit:
line 3:
aw-watcher-vim: Failed to connect to aw-server, logging will be disabled. You can retry to connect with ':AWStart'
I don't know how to further debug this, based on this part of the code from the plugin:
let s:connected = 0
let s:apiurl_host = get(g:, 'aw_apiurl_host', '127.0.0.1')
let s:apiurl_port = get(g:, 'aw_apiurl_port', '5600')
let s:api_timeout = get(g:, 'aw_api_timeout', 2)
let s:base_apiurl = printf('http://%s:%s/api/0', s:apiurl_host, s:apiurl_port)
let s:hostname = get(g:, 'aw_hostname', hostname())
let s:bucketname = printf('aw-watcher-vim_%s', s:hostname)
let s:bucket_apiurl = printf('%s/buckets/%s', s:base_apiurl, s:bucketname)
let s:heartbeat_apiurl = printf('%s/heartbeat?pulsetime=30', s:bucket_apiurl)
So here is the output of the curl -s 'http://127.0.0.1:5600/api/0/buckets/aw-watcher-vim_MMCH:
{"id": "aw-watcher-vim_MMCH", "created": "2021-08-02T14:56:22.351816+00:00", "name": null, "type": "app.editor.activity", "client": "aw-watcher-vim", "hostname": "MMCH"}
and here the heartbeat_apiurl which the API doesn't respond. The above show the name and spelling of bucket is correct yet this url doesn't get proper response:
query: curl -s 'http://127.0.0.1:5600/api/0/buckets/aw-watcher-vim_MMCH/heartbeat?pulsetime=30'
<!doctype html>
<html lang=en>
<title>404 Not Found</title>
<h1>Not Found</h1>
<p>The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.</p>
Is there no fix for this yet?