Skip to content

Commit 1033e7b

Browse files
authored
Clear timeout on dispose (#7072)
* Clear timeout on dispose * Only register once
1 parent 75ecee0 commit 1033e7b

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/github/copilotPrWatcher.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,13 +116,15 @@ export class CopilotPRWatcher extends Disposable {
116116
this._pollForChanges();
117117
}
118118
}));
119+
this._register({ dispose: () => this._timeout && clearTimeout(this._timeout) });
119120
}
120121

121122
private _queriesIncludeCopilot(): string | undefined {
122123
const queries = vscode.workspace.getConfiguration(PR_SETTINGS_NAMESPACE).get<{ label: string; query: string }[]>(QUERIES, []);
123124
return queries.find(query => isCopilotQuery(query.query))?.query;
124125
}
125126

127+
private _timeout: NodeJS.Timeout | undefined;
126128
private async _pollForChanges(): Promise<void> {
127129
const query = this._queriesIncludeCopilot();
128130
if (!query) {
@@ -131,7 +133,7 @@ export class CopilotPRWatcher extends Disposable {
131133

132134
await this._getStateChanges(query);
133135

134-
setTimeout(() => {
136+
this._timeout = setTimeout(() => {
135137
this._pollForChanges();
136138
}, 60 * 1000); // Poll every minute
137139
}

0 commit comments

Comments
 (0)