Skip to content

Commit 809cf95

Browse files
Merge pull request #142 from codacy/fix-timeout
fix multiple timeouts
2 parents 2519f4b + ee8b46e commit 809cf95

1 file changed

Lines changed: 3 additions & 8 deletions

File tree

src/git/CodacyCloud.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -105,26 +105,21 @@ export class CodacyCloud implements vscode.Disposable {
105105

106106
try {
107107
// Check if repository state is fully populated
108-
if (!gitRepository.state.HEAD && gitRepository.state.remotes?.length === 0) {
108+
if (!gitRepository.state.HEAD && gitRepository.state.remotes?.length === 0 && !this._stateChangeDisposable) {
109109
Logger.debug('Repository state is not fully populated yet, waiting for state change...')
110110
this.state = CodacyCloudState.Initializing
111111

112-
// Clean up any existing state change listener
113-
if (this._stateChangeDisposable) {
114-
this._stateChangeDisposable.dispose()
115-
this._stateChangeDisposable = undefined
116-
}
117-
118112
// Set up timeout to prevent memory leak
119113
const timeoutMs = 30000
120114
let hasRepositoryStateTimedOut = false
121115
const repositoryStateTimeout = setTimeout(() => {
122116
hasRepositoryStateTimedOut = true
123-
Logger.appendLine(`Repository state change timeout after ${timeoutMs}ms, assuming repository is not valid`)
124117
if (this._stateChangeDisposable) {
125118
this._stateChangeDisposable.dispose()
126119
this._stateChangeDisposable = undefined
127120
}
121+
122+
Logger.appendLine(`Repository state change timeout after ${timeoutMs}ms, assuming repository is not valid`)
128123
this.state = CodacyCloudState.NoGitRepository
129124
}, timeoutMs)
130125

0 commit comments

Comments
 (0)