Skip to content

Commit 926dbda

Browse files
Make branch list timeout configurable (#2840) (#7927)
1 parent d6002d2 commit 926dbda

File tree

4 files changed

+12
-2
lines changed

4 files changed

+12
-2
lines changed

package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,12 @@
175175
"description": "%githubPullRequests.logLevel.description%",
176176
"markdownDeprecationMessage": "%githubPullRequests.logLevel.markdownDeprecationMessage%"
177177
},
178+
"githubPullRequests.branchListTimeout": {
179+
"type": "number",
180+
"default": 5000,
181+
"minimum": 1000,
182+
"markdownDescription": "%githubPullRequests.branchListTimeout.description%"
183+
},
178184
"githubPullRequests.remotes": {
179185
"type": "array",
180186
"default": [

package.nls.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"{Locked='](command:workbench.action.setLogLevel)'}"
2121
]
2222
},
23+
"githubPullRequests.branchListTimeout.description": "Maximum time in milliseconds to wait when fetching the list of branches for pull request creation. Repositories with thousands of branches may need a higher value to ensure all branches (including the default branch) are retrieved. Minimum value is 1000 (1 second).",
2324
"githubPullRequests.codingAgent.description": "Enables integration with the asynchronous Copilot coding agent. The '#copilotCodingAgent' tool will be available in agent mode when this setting is enabled.",
2425
"githubPullRequests.codingAgent.uiIntegration.description": "Enables UI integration within VS Code to create new coding agent sessions.",
2526
"githubPullRequests.codingAgent.autoCommitAndPush.description": "Allow automatic git operations (commit, push) to be performed when starting a coding agent session",

src/common/settingKeys.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
export const PR_SETTINGS_NAMESPACE = 'githubPullRequests';
77
export const TERMINAL_LINK_HANDLER = 'terminalLinksHandler';
88
export const BRANCH_PUBLISH = 'createOnPublishBranch';
9+
export const BRANCH_LIST_TIMEOUT = 'branchListTimeout';
910
export const USE_REVIEW_MODE = 'useReviewMode';
1011
export const FILE_LIST_LAYOUT = 'fileListLayout';
1112
export const HIDE_VIEWED_FILES = 'hideViewedFiles';

src/github/githubRepository.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { AuthenticationError, AuthProvider, GitHubServerType, isSamlError } from
1111
import { Disposable, disposeAll } from '../common/lifecycle';
1212
import Logger from '../common/logger';
1313
import { GitHubRemote, parseRemote } from '../common/remote';
14+
import { BRANCH_LIST_TIMEOUT, PR_SETTINGS_NAMESPACE } from '../common/settingKeys';
1415
import { ITelemetry } from '../common/telemetry';
1516
import { PullRequestCommentController } from '../view/pullRequestCommentController';
1617
import { PRCommentControllerRegistry } from '../view/pullRequestCommentControllerRegistry';
@@ -1196,6 +1197,7 @@ export class GitHubRepository extends Disposable {
11961197
const branches: string[] = [];
11971198
const defaultBranch = (await this.getMetadataForRepo(owner, repositoryName)).default_branch;
11981199
const startingTime = new Date().getTime();
1200+
const timeout = vscode.workspace.getConfiguration(PR_SETTINGS_NAMESPACE).get<number>(BRANCH_LIST_TIMEOUT, 5000);
11991201

12001202
do {
12011203
try {
@@ -1210,8 +1212,8 @@ export class GitHubRepository extends Disposable {
12101212
});
12111213

12121214
branches.push(...data.repository.refs.nodes.map(node => node.name));
1213-
if (new Date().getTime() - startingTime > 5000) {
1214-
Logger.warn('List branches timeout hit.', this.id);
1215+
if (new Date().getTime() - startingTime > timeout) {
1216+
Logger.warn(`List branches timeout hit after ${timeout}ms.`, this.id);
12151217
break;
12161218
}
12171219
hasNextPage = data.repository.refs.pageInfo.hasNextPage;

0 commit comments

Comments
 (0)