microsoft / vscode-pull-request-github

GitHub Pull Requests for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=GitHub.vscode-pull-request-github
MIT License
2.26k stars 554 forks source link

Extension gets rate limited in a many-repo setup: http forbidden response when adding reviewer after creating pull request #6042

Open qrkourier opened 3 weeks ago

qrkourier commented 3 weeks ago

Type: Bug

  1. run vscode flatpak
  2. install gh pull requests extension
  3. authenticate to github
  4. integrated terminal: git push
  5. integrated terminal: click link to create pr
  6. extension widget appears: click to create pull request
  7. pull request preview appears: click to add reviewer
  8. get 403 error toast

Extension version: 0.88.1 VS Code version: Code 1.89.1 (dc96b837cf6bb4af9cd736aa3af08cf8279f7685, 2024-05-07T05:16:23.416Z) OS version: Linux x64 6.8.0-76060800daily20240311-generic Modes:

System Info |Item|Value| |---|---| |CPUs|12th Gen Intel(R) Core(TM) i5-12600K (16 x 4453)| |GPU Status|2d_canvas: enabled
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: enabled
video_encode: disabled_software
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: disabled_off| |Load (avg)|2, 2, 1| |Memory (System)|62.56GB (34.63GB free)| |Process Argv|--ms-enable-electron-run-as-node --extensions-dir=/home/kbingham/.var/app/com.visualstudio.code/data/vscode/extensions --add /home/kbingham/Sites/netfoundry/bin/test-build-linux-docker.bash --crash-reporter-id aa778439-0ba0-4494-b7f6-45df1086173f| |Screen Reader|no| |VM|8%| |DESKTOP_SESSION|pop| |XDG_CURRENT_DESKTOP|Unity| |XDG_SESSION_DESKTOP|pop| |XDG_SESSION_TYPE|x11|
A/B Experiments ``` vsliv368cf:30146710 vspor879:30202332 vspor708:30202333 vspor363:30204092 vscoreces:30445986 vscod805cf:30301675 binariesv615:30325510 vsaa593cf:30376535 py29gd2263:31024239 c4g48928:30535728 azure-dev_surveyone:30548225 962ge761:30959799 pythongtdpath:30769146 welcomedialog:30910333 pythonidxpt:30866567 pythonnoceb:30805159 asynctok:30898717 pythontestfixt:30902429 pythonregdiag2:30936856 pythonmypyd1:30879173 pythoncet0:30885854 h48ei257:31000450 pythontbext0:30879054 accentitlementsc:30995553 dsvsc016:30899300 dsvsc017:30899301 dsvsc018:30899302 cppperfnew:31000557 dsvsc020:30976470 pythonait:31006305 666c4381:31064718 chatpanelt:31048053 dsvsc021:30996838 01bff139:31013167 pythoncenvpt:31062603 a69g1124:31058053 dvdeprecation:31061160 pythonprt:31056678 dwnewjupyter:31046869 26j00206:31048877 ```
alexr00 commented 1 week ago

Can you share the output from GitHub Pull Request?

qrkourier commented 1 week ago

Sure, @alexr00. github-pull-request-ext-output.txt

alexr00 commented 1 week ago

Thanks! Are you able to add a reviewer on github.com in that repo?

qrkourier commented 1 week ago

Yes. I only encounter the problem when I try to add a reviewer with the extension.

alexr00 commented 6 days ago

@qrkourier are you using a Codespace, or is this local development?

qrkourier commented 6 days ago

Local only

alexr00 commented 6 days ago

Hmm, there goes that theory. We've had issues with the auth token in Codspaces before.

I see you have a multi-repo workspace open. Do you use the same GitHub login for each of those repos? Maybe we're somehow trying to use the wrong account to set the reviewer. Could you try signing out of GitHub in VS Code (from the Account icon in the activity bar), reload, then sign back in again?

Thanks for your patience with these questions.

qrkourier commented 5 days ago

I signed out of GitHub in VS Code by mousing to bottom-left and unfolding the accounts widget. I then tried to create a new PR in the usual way: do git push in the integrated terminal, ctrl-left-click the "Create a pull request ... by visiting ..." link in the terminal, then completing the PR in the extension's sidebar.

Typically, the finished PR is then opened in a tab, and I would then encounter the 403 error when attempting to further modify the PR, e.g., add a reviewer.

This time the 403 presented immediately after submitting the form in the sidebar, so the tab was opened but never loaded. It's stuck displaying "loading..."

Upon navigating to the repo in GitHub.com I see the PR was created, so the 403 seems to have recurred immediately after successfully creating the PR, and prevented the extension from loading it in a VS Code tab.

Here's the extension output from the last few minutes. I attempted to include the lines beginning at the moment when I became re-authenticated, assuming the lines above that wouldn't be interesting.

github-pull-request-ext-2024-06-28 11:42:10.txt

qrkourier commented 5 days ago

Oops, I forgot to answer your question. Yes, I am using only a single GitHub account with this VS Code workspace.

alexr00 commented 3 days ago

I think I've found the reason this happens:

 Fetching default branch failed: HttpError: You have exceeded a secondary rate limit.

The secondary rate limit happens when your account makes too many GitHub API requests in a short period of time. Give your many-repo setup, the extension is making many API requests. I'll need to see if there are places I can dramatically reduce this.

alexr00 commented 3 days ago

How many repos do you have open? 15?

qrkourier commented 3 days ago

Thank you for clarifying it's a resource constraint that may be worked around by limiting the count of folders added to the VS Code workspace that represent GitHub repositories.

The repositories I use most frequently in VS Code are GitHub repositories.

It's not difficult to add and remove folders in the workspace, and it's convenient for full-indexing to have 10-40 repos open simultaneously, system resources permitting.

I'll make sure to report back if I can't reproduce this issue while working with fewer GitHub repos in VS Code.

Idea: parse the rate limit message from the log to provide an informative toast or retry behavior?