Skip to content

Commit 9ae0755

Browse files
committed
fix(server_job): better error logging
I've seen a few times where job_count stays at 1 when i try to cancel a request. I'm wondering if one of these handlers is erroring out.
1 parent aef8f85 commit 9ae0755

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

lua/opencode/server_job.lua

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,25 @@ function M.call_api(url, method, body)
3434
callback = function(response)
3535
handle_api_response(response, function(err, result)
3636
if err then
37-
call_promise:reject(err)
37+
local ok, pcall_err = pcall(call_promise.reject, call_promise, err)
38+
if not ok then
39+
vim.notify('Error while handling API error response: ' .. vim.inspect(pcall_err))
40+
end
3841
state.job_count = state.job_count - 1
3942
else
40-
call_promise:resolve(result)
43+
local ok, pcall_err = pcall(call_promise.resolve, call_promise, result)
44+
if not ok then
45+
vim.notify('Error while handling API response: ' .. vim.inspect(pcall_err))
46+
end
4147
state.job_count = state.job_count - 1
4248
end
4349
end)
4450
end,
4551
on_error = function(err)
46-
call_promise:reject(err)
52+
local ok, pcall_err = pcall(call_promise.reject, call_promise, err)
53+
if not ok then
54+
vim.notify('Error while handling API on_error: ' .. vim.inspect(pcall_err))
55+
end
4756
state.job_count = state.job_count - 1
4857
end,
4958
}

0 commit comments

Comments
 (0)