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

Plugin Updates rate limited by Github #9127

Closed
2 tasks done
prokizzle opened this issue Apr 17, 2023 · 8 comments · Fixed by #9609
Closed
2 tasks done

Plugin Updates rate limited by Github #9127

prokizzle opened this issue Apr 17, 2023 · 8 comments · Fixed by #9609
Labels
estimate: medium Medium effort required proxy :type/enhancement Enhancement to product. Does not affect the overall basic use.

Comments

@prokizzle
Copy link

Search first

  • I searched and no similar issues were found

What Happened?

I performed Check for Updates on plugin page. I recieved errors about rate limit from github when looking for updates. I was unable to update plugins found to have updates.

Reproduce the Bug

  1. Go to plugins modal
  2. Click the vertical dots menu
  3. Select Check All Updates

Expected Behavior

I expect to see a list of updates or not see error popups

Screenshots

CleanShot 2023-04-17 at 13 36 50

Desktop or Mobile Platform Information

macOS 13.3.1 M1 Macbook Pro LogSeq 0.9.2

Additional Context

No response

Are you willing to submit a PR? If you know how to fix the bug.

  • I'm willing to submit a PR (Thank you!)
@prokizzle
Copy link
Author

Adding a github login option could allow all update requests to be authenticated, resulting in a higher rate limit.

@cnrpman cnrpman added proxy :type/enhancement Enhancement to product. Does not affect the overall basic use. labels Apr 18, 2023
@cnrpman
Copy link
Collaborator

cnrpman commented Apr 18, 2023

Good point. PR is welcome

@shlomi-dr
Copy link

Experiencing the same problem..

@prokizzle
Copy link
Author

Good point. PR is welcome

Any advice at where to start looking for the plugin update code?

@shlomi-dr
Copy link

Not familiar with the code at all, but perhaps this is a clue?

(defn- fetch-release-asset
[{:keys [repo theme]} url-suffix {:keys [response-transform]
:or {response-transform identity}}]
(-> (p/let [repo (some-> repo (string/trim) (string/replace #"^/+(.+?)/+$" "$1"))
api #(str "https://api.github.com/repos/" repo "/" %)
endpoint (api url-suffix)
^js res (fetch endpoint)
illegal-text (when-not (= 200 (.-status res)) (.text res))
_ (when-not (string/blank? illegal-text) (throw (js/Error. (str "Github API Failed(" (.-status res) ") " illegal-text))))
_ (debug "[Release URL] " endpoint "[Status/Text]" (.-status res))
res (response-transform res)
res (.json res)
res (bean/->clj res)
version (:tag_name res)
asset (first (filter #(string/ends-with? (:name %) ".zip") (:assets res)))]
[(if (and (nil? asset) theme)
(if-let [zipball (:zipball_url res)]
zipball
(api "zipball"))
asset)
version
(:body res)])
(p/catch
(fn [^js e]
(debug e)
(throw (js/Error. [:release-channel-issue (.-message e)]))))))

@prokizzle
Copy link
Author

prokizzle commented May 9, 2023

So I assume the strategy is to add an Authorization header to the fetch call for the github release zipball endoint. Probably needs a core plugin to handle a UI for inputting the token, with a link to generate one on gh with the necessary permissions.

Also should probably handle token expiry, since gh strongly discourages creating tokens that don't expire.

@cnrpman cnrpman added the estimate: medium Medium effort required label May 24, 2023
@cnrpman
Copy link
Collaborator

cnrpman commented May 24, 2023

Thank you guys for the investigation!
Feel free to ping if there's any issue about development.

@cnrpman
Copy link
Collaborator

cnrpman commented Jun 11, 2023

Related ticket: #9581 #5847

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
estimate: medium Medium effort required proxy :type/enhancement Enhancement to product. Does not affect the overall basic use.
Projects
Development

Successfully merging a pull request may close this issue.

3 participants