gitkraken / vscode-gitlens

Supercharge Git inside VS Code and unlock untapped knowledge within each repository — Visualize code authorship at a glance via Git blame annotations and CodeLens, seamlessly navigate and explore Git repositories, gain valuable insights via rich visualizations and powerful comparison commands, and so much more
http://gitkraken.com/gitlens
Other
9.02k stars 1.35k forks source link

Too many requests to github #1869

Open smiklos opened 2 years ago

smiklos commented 2 years ago

Since the latest update to 12 We are getting rejected from accessing Github because we get rate limited, presumably because of the many requests this plugin makes. I have no further proof yet, but it started two days ago , exactly when the new version was released.

I will try to provide logs later but perhaps someone can look into this already.

eps1lon commented 2 years ago

Issue persists on GitLens Version 12.0.1

hans2520 commented 2 years ago

Have been getting spammed constantly with:

GitHub request failed: API rate limit exceeded for user ID xxxx

Source: GitLens --- Git supercharged (Extension)

v12.0.1 installed

eamodio commented 2 years ago

I'm sorry for the trouble. Can you please enable debug logging by running from GitLens: Enable Debug Logging from the Command Palette (F1 or ctrl/cmd+shift+p). This will enable logging to the GitLens and GitLens (Git) channel in the Output pane.

Once enabled, please reproduce the issue, and attach the log from the both GitLens and GitLens (Git) channels.

Thank you!

FYI, I will also be adding better handling of rate limit issues, but I really want to understand why GitLens would be making so many calls.

smiklos commented 2 years ago

The issue is not just that I get blocked out but the whole office network is detected as malicious and we can't access github. Even users who don't even use vscode are blocked. Me having to reproduce this is not feasible.

On Wed, 9 Mar 2022, 07.27 Eric Amodio, @.***> wrote:

I'm sorry for the trouble. Can you please enable debug logging by running from GitLens: Enable Debug Logging from the Command Palette (F1 or ctrl/cmd+shift+p). This will enable logging to the GitLens and GitLens (Git) channel in the Output pane.

Once enabled, please reproduce the issue, and attach the log from the both GitLens and GitLens (Git) channels.

Thank you!

FYI, I will also be adding better handling of rate limit issues, but I really want to understand why GitLens would be making so many calls.

— Reply to this email directly, view it on GitHub https://github.com/gitkraken/vscode-gitlens/issues/1869#issuecomment-1062595324, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAYR27F4P3FYHSVATEBIZNDU7BAGPANCNFSM5PXOXD4A . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you authored the thread.Message ID: @.***>

eps1lon commented 2 years ago

I'll enable debugging and try to reproduce this. I encountered it multiple times already on public GitHub repositories so this should hopefully reproduce with logs.

eamodio commented 2 years ago

Just pinging if anyone can provide logs -- because I'm really not sure what could be causing lots of requests. GitLens only makes requests a handful of requests generally in response to direct user action (other than checking for a PR associated with the current branch -- but it only does that once and when the repo changes). Other requests are done to check for PRs when changing the active line (which seems like the most likely candidate -- but still hard to see hitting limits there), or expanding commits in the views, or in the hovers. The only place where GitLens can make a series of requests is if you use the new Autolinked Isssues & PR feature in comparisons -- since that will make a request for each issue/PR found.

Also for users hitting this you disconnect GitLens from GitHub with the GitLens: Disconnect from Remote command or by setting the gitlens.integrations.enabled setting to false for the time being.

Again, really sorry for the trouble.

eps1lon commented 2 years ago

What I see in the logs is that just by moving a cursor to a line GitLens sends a request to issuesOrPullRequest (e.g. [2022-03-11 19:44:43.590] [ 1085] GitHubApi.getIssueOrPullRequest completed • 291 ms.

This seems too eager to me. Or at least I'd like to understand what information I would loose by not hitting the API at this point.

full log just for clicking on a line ``` [2022-03-11 19:49:13.010] [ 1a93] LineAnnotationController.onActiveLinesChanged — e=editor=file:///home/eps1lon/Development/forks/react-testing-library/src/pure.js, selections=undefined, pending=true, reason=selection [2022-03-11 19:49:13.010] [ 1a94] LineAnnotationController.clear completed • 0 ms [2022-03-11 19:49:13.010] [ 1a93] LineAnnotationController.onActiveLinesChanged completed • 0 ms [2022-03-11 19:49:13.010] [ 1a95] LineHoverController.onActiveLinesChanged — e=editor=file:///home/eps1lon/Development/forks/react-testing-library/src/pure.js, selections=undefined, pending=true, reason=selection [2022-03-11 19:49:13.010] [ 1a95] LineHoverController.onActiveLinesChanged completed • 0 ms [2022-03-11 19:49:13.010] [ 1a96] StatusBarController.onActiveLinesChanged — e=editor=file:///home/eps1lon/Development/forks/react-testing-library/src/pure.js, selections=undefined, pending=true, reason=selection [2022-03-11 19:49:13.011] [ 1a96] StatusBarController.onActiveLinesChanged completed • 0 ms [2022-03-11 19:49:13.262] [ 1a98] GitProviderService.getBlameForLine — H=GitUri(file:///home/eps1lon/Development/forks/react-testing-library/src/pure.js repoPath=/home/eps1lon/Development/forks/react-testing-library), Q=15, ee={"uri":{"$mid":1,"fsPath":"/home/eps1lon/Development/forks/react-testing-library/src/pure.js","external":"file:///home/eps1lon/Development/forks/react-testing-library/src/pure.js","path":"/home/eps1lon/Development/forks/react-testing-library/src/pure.js","scheme":"file"},"fileName":"/home/eps1lon/Development/forks/react-testing-library/src/pure.js","isUntitled":false,"languageId":"javascript","version":1,"isClosed":false,"isDirty":false,"eol":1,"lineCount":226} [2022-03-11 19:49:13.262] [ 1a99] LocalGitProvider.getBlameForLine — e=GitUri(file:///home/eps1lon/Development/forks/react-testing-library/src/pure.js repoPath=/home/eps1lon/Development/forks/react-testing-library), t=15, n={"uri":{"$mid":1,"fsPath":"/home/eps1lon/Development/forks/react-testing-library/src/pure.js","external":"file:///home/eps1lon/Development/forks/react-testing-library/src/pure.js","path":"/home/eps1lon/Development/forks/react-testing-library/src/pure.js","scheme":"file"},"fileName":"/home/eps1lon/Development/forks/react-testing-library/src/pure.js","isUntitled":false,"languageId":"javascript","version":1,"isClosed":false,"isDirty":false,"eol":1,"lineCount":226}, a=undefined [2022-03-11 19:49:13.262] [ 1a9a] LocalGitProvider.getBlame — e=GitUri(file:///home/eps1lon/Development/forks/react-testing-library/src/pure.js repoPath=/home/eps1lon/Development/forks/react-testing-library) [2022-03-11 19:49:13.263] [ 1a9a] LocalGitProvider.getBlame Cache hit: 'blame' [2022-03-11 19:49:13.263] [ 1a9a] LocalGitProvider.getBlame completed • 0 ms [2022-03-11 19:49:13.263] [ 1a99] LocalGitProvider.getBlameForLine completed • 0 ms [2022-03-11 19:49:13.263] [ 1a98] GitProviderService.getBlameForLine completed • 1 ms [2022-03-11 19:49:13.263] [ 1a97] GitLineTracker.updateState returned true • 1 ms — e=15, t=file:///home/eps1lon/Development/forks/react-testing-library/src/pure.js [2022-03-11 19:49:13.263] [ 1a9b] LineAnnotationController.onActiveLinesChanged — e=editor=file:///home/eps1lon/Development/forks/react-testing-library/src/pure.js, selections=[15-15], pending=false, reason=selection [2022-03-11 19:49:13.263] [ 1a9c] LineAnnotationController.refresh [2022-03-11 19:49:13.263] [ 1a9b] LineAnnotationController.onActiveLinesChanged completed • 0 ms [2022-03-11 19:49:13.263] [ 1a9d] LineHoverController.onActiveLinesChanged — e=editor=file:///home/eps1lon/Development/forks/react-testing-library/src/pure.js, selections=[15-15], pending=false, reason=selection [2022-03-11 19:49:13.263] [ 1a9d] LineHoverController.onActiveLinesChanged completed • 0 ms [2022-03-11 19:49:13.263] [ 1a9e] StatusBarController.onActiveLinesChanged — e=editor=file:///home/eps1lon/Development/forks/react-testing-library/src/pure.js, selections=[15-15], pending=false, reason=selection [2022-03-11 19:49:13.263] [ 1a9f] StatusBarController.updateBlame [2022-03-11 19:49:13.263] [ 1aa0] GitProviderService.getRichRemoteProvider — H=/home/eps1lon/Development/forks/react-testing-library [2022-03-11 19:49:13.264] [ 1a9e] StatusBarController.onActiveLinesChanged completed • 0 ms [2022-03-11 19:49:13.264] [ 1aa0] GitProviderService.getRichRemoteProvider completed • 0 ms [2022-03-11 19:49:13.264] [ 1aa1] GitProviderService.getRichRemoteProvider — H=/home/eps1lon/Development/forks/react-testing-library [2022-03-11 19:49:13.264] [ 1aa2] GitProviderService.getPullRequestForCommit — H=ba24a4be96469a5c3e004c186e19c1a57b2fd999, Q=GitHub, ee={"timeout":100} [2022-03-11 19:49:13.264] [ 1aa3] GitHubRemote.getPullRequestForCommit — O=ba24a4be96469a5c3e004c186e19c1a57b2fd999 [2022-03-11 19:49:13.265] [ 1aa3] GitHubRemote.getPullRequestForCommit completed • 0 ms [2022-03-11 19:49:13.265] [ 1aa1] GitProviderService.getRichRemoteProvider completed • 0 ms [2022-03-11 19:49:13.265] [ 1aa2] GitProviderService.getPullRequestForCommit completed • 0 ms [2022-03-11 19:49:13.265] [ 1aa4] GitProviderService.getPullRequestForCommit — H=ba24a4be96469a5c3e004c186e19c1a57b2fd999, Q=GitHub [2022-03-11 19:49:13.265] [ 1aa5] GitHubRemote.getPullRequestForCommit — O=ba24a4be96469a5c3e004c186e19c1a57b2fd999 [2022-03-11 19:49:13.265] [ 1aa5] GitHubRemote.getPullRequestForCommit completed • 0 ms [2022-03-11 19:49:13.265] [ 1aa4] GitProviderService.getPullRequestForCommit completed • 0 ms [2022-03-11 19:49:13.266] [ 1a9f] StatusBarController.updateBlame completed • 2 ms [2022-03-11 19:49:13.266] [ 1a9c] LineAnnotationController.refresh completed • selection(s)=[15-15] • 3 ms [2022-03-11 19:49:13.766] [ 1aa6] GitProviderService.getRemotesWithProviders — H=/home/eps1lon/Development/forks/react-testing-library, Q={"sort":true} [2022-03-11 19:49:13.766] [ 1aa7] GitProviderService.getRepository — H=/home/eps1lon/Development/forks/react-testing-library [2022-03-11 19:49:13.766] [ 1aa7] GitProviderService.getRepository returned /home/eps1lon/Development/forks/react-testing-library • 0 ms [2022-03-11 19:49:13.766] [ 1aa6] GitProviderService.getRemotesWithProviders completed • 0 ms [2022-03-11 19:49:13.766] [ 6824] Hovers.getAutoLinkedIssuesOrPullRequests — message= [2022-03-11 19:49:13.766] [ 1aa9] GitProviderService.getRichRemoteProvider — H=origin,upstream [2022-03-11 19:49:13.766] [ 1aaa] VslsController.maybeGetPresence — silbermann.sebastian@gmail.com [2022-03-11 19:49:13.766] [ 1aab] VslsController.getContactPresence — e=silbermann.sebastian@gmail.com [2022-03-11 19:49:13.766] [ 1aac] VslsController.getContact — e=silbermann.sebastian@gmail.com [2022-03-11 19:49:13.766] [ 1aa9] GitProviderService.getRichRemoteProvider completed • 0 ms [2022-03-11 19:49:13.766] [ 1aac] VslsController.getContact completed • 0 ms [2022-03-11 19:49:13.766] [ 1aad] Autolinks.getIssueOrPullRequestLinks — , 250 [2022-03-11 19:49:13.766] [ 1aae] GitHubRemote.getIssueOrPullRequest — O=1018 [2022-03-11 19:49:13.766] [ 1aab] VslsController.getContactPresence completed • 0 ms [2022-03-11 19:49:13.766] [ 1aaf] GitHubApi.getIssueOrPullRequest — i=GitHub, , o=eps1lon, s=react-testing-library, u=1018, c={"baseUrl":"https://api.github.com"} [2022-03-11 19:49:13.767] [ 1aaa] VslsController.maybeGetPresence completed • 0 ms [2022-03-11 19:49:13.995] [ 1aaf] GitHubApi.getIssueOrPullRequest completed • 228 ms [2022-03-11 19:49:13.995] [ 1aae] GitHubRemote.getIssueOrPullRequest completed • 229 ms [2022-03-11 19:49:13.995] [ 1aad] Autolinks.getIssueOrPullRequestLinks completed • 229 ms [2022-03-11 19:49:13.995] [ 6824] Hovers.getAutoLinkedIssuesOrPullRequests completed • 229 ms [2022-03-11 19:49:13.996] [ 1ab0] Autolinks.linkify — , t=true, n=2, a=undefined, f=1 [2022-03-11 19:49:13.997] [ 1ab0] Autolinks.linkify completed • 0 ms [2022-03-11 19:49:13.997] [ 1ab1] GitProviderService.getRevisionUri — H=1ba40c913afa7827fc711f4af7b1b06f4a900870, Q=src/pure.js, ee=/home/eps1lon/Development/forks/react-testing-library [2022-03-11 19:49:13.997] [ 1ab1] GitProviderService.getRevisionUri completed • 0 ms [2022-03-11 19:49:13.997] [ 1ab2] GitProviderService.getRevisionUri — H=GitUri(file:///home/eps1lon/Development/forks/react-testing-library/src/pure.js repoPath=/home/eps1lon/Development/forks/react-testing-library sha=ba24a4be96469a5c3e004c186e19c1a57b2fd999) [2022-03-11 19:49:13.998] [ 1ab2] GitProviderService.getRevisionUri completed • 0 ms ```
eamodio commented 2 years ago

@eps1lon yeah, it does make a request for each commit that you move the cursor to (only once per commit tho).

You can see (and toggle) that behavior here: image

Also in those logs all of those calls look like they are reading from cache as they are completing in 0ms.

[2022-03-11 19:49:13.264] [ 1aa3] GitHubRemote.getPullRequestForCommit — O=ba24a4be96469a5c3e004c186e19c1a57b2fd999
[2022-03-11 19:49:13.265] [ 1aa3] GitHubRemote.getPullRequestForCommit completed • 0 ms
eps1lon commented 2 years ago

Also in those logs all of those calls look like they are reading from cache as they are completing in 0ms.

2 of the 3, yes. 1 still went through.

You can see (and toggle) that behavior here:

I don't want to turn it off. I just don't need it when the cursor is on the commit. Will try with it turned off though for now.

eamodio commented 2 years ago

@eps1lon Turning that setting off -- will just turn off the querying as you move the cursor around (since it won't be trying to add the PR information into the current line blame annotation). It will still query if you hover, or any of the other places. GitLens has lots of granular control over what you want to see when and where.

github-actions[bot] commented 2 years ago

This issue needs more information and has not had recent activity. Please provide the missing information or it will be closed in 7 days. Thanks!

eps1lon commented 2 years ago

I also have "GitHub Pull Requests and Issues" installed which seems to have similar issues: https://github.com/microsoft/vscode-pull-request-github/issues/3409#issuecomment-1072736656