-
-
Notifications
You must be signed in to change notification settings - Fork 32
Description
Summary
Elixir Tools uses the GitHub unauthenticated API to check for new releases of the "tools" every time the editor is started and plugin is loaded. For users of ElixirLS, NextLS and Credo LSP that's 3 calls total on every start.
Whenever reaching the API rate limit of the GitHub unauthenticated API, ElixirTools fails to start.
Reproduction Steps
- Reach the rate limit of unauthenticated API calls (to simulate this, call the API as the plugin does, but repeat 60 times):
repeat 60 curl --silent -i -L -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" https://api.github.com/repos/elixir-tools/credo-language-server/releases/latest
- Open an Elixir file in Neovim, to make the plugin load
Expected
The Elixir file opens and a notification shows that the latest version of ElixirLS/CredoLS/NextLS cannot be checked due to a rate limit
Actual
ElixirTools fails to start with this error:
This breaks all LSP functionality
Cause
This error originates from this line
elixir-tools.nvim/lua/elixir/utils.lua
Line 55 in 883933b
assert(type(version) == "string") |
I confirmed this was due to a rate limit being hit
And it is likely due to the assumption that curl
would return an error code in this case, but it does not:

From GitHub rate limiting docs:
Suggested Solution
- Add
--fail
to the curl command inlatest_release
, to make it return an error code on failed attempts - Adjust the notification error to mention something about rate limits
elixir-tools.nvim/lua/elixir/utils.lua
Line 63 in 883933b
vim.notify(


Alternatively, we can find a way to use the developer's GitHub auth token as part of the request, which will then increase the rate limit to 5,000 per hour which is less likely to be hit, but that seems a tad more complicated.
I'm happy to post a PR for this if my first solution sounds like a good approach.