Skip to content

Commit 1326aaa

Browse files
Copilotrebornix
andcommitted
Add timeout-based polling to streamSessionLogs method in copilotRemoteAgent.ts
Co-authored-by: rebornix <876920+rebornix@users.noreply.github.com>
1 parent 47f3e96 commit 1326aaa

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

src/github/copilotRemoteAgent.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1185,6 +1185,8 @@ export class CopilotRemoteAgentManager extends Disposable {
11851185
let lastProcessedLength = 0;
11861186
let hasActiveProgress = false;
11871187
const pollingInterval = 3000; // 3 seconds
1188+
const maxWaitTime = 60 * 60 * 1000; // 1 hour timeout for long-running sessions
1189+
const startTime = Date.now();
11881190

11891191
return new Promise<void>((resolve, reject) => {
11901192
let cancellationListener: vscode.Disposable | undefined;
@@ -1229,6 +1231,14 @@ export class CopilotRemoteAgentManager extends Disposable {
12291231
return;
12301232
}
12311233

1234+
// Check for timeout
1235+
if (Date.now() - startTime > maxWaitTime) {
1236+
Logger.appendLine(`Session polling timed out after ${maxWaitTime / 1000} seconds`, CopilotRemoteAgentManager.ID);
1237+
stream.markdown(vscode.l10n.t('Session polling timed out. The session may still be running.'));
1238+
complete();
1239+
return;
1240+
}
1241+
12321242
// Get the specific session info
12331243
const sessionInfo = await capi.getSessionInfo(sessionId);
12341244
if (!sessionInfo || token.isCancellationRequested) {
@@ -1286,7 +1296,7 @@ export class CopilotRemoteAgentManager extends Disposable {
12861296
}
12871297
} catch (error) {
12881298
Logger.error(`Error polling for session updates: ${error}`, CopilotRemoteAgentManager.ID);
1289-
if (!token.isCancellationRequested) {
1299+
if (!token.isCancellationRequested && Date.now() - startTime <= maxWaitTime) {
12901300
setTimeout(pollForUpdates, pollingInterval);
12911301
} else {
12921302
reject(error);

0 commit comments

Comments
 (0)