Skip to content

Commit 91cb0dc

Browse files
committed
fix: add exponential backoff to configure timeout, set Error.name, clear lastConfiguration on failure (PR #1275)
1 parent d7a192e commit 91cb0dc

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/managers/common/nativePythonFinder.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ class RpcTimeoutError extends Error {
129129
timeoutMs: number,
130130
) {
131131
super(`Request '${method}' timed out after ${timeoutMs}ms`);
132+
this.name = this.constructor.name;
132133
}
133134
}
134135

@@ -600,12 +601,21 @@ class NativePythonFinderImpl implements NativePythonFinder {
600601
return;
601602
}
602603
this.outputChannel.info('[pet] configure: Sending configuration update:', JSON.stringify(options));
604+
// Exponential backoff: 30s, 60s on retry. Capped at REFRESH_TIMEOUT_MS.
605+
const timeoutMs = Math.min(CONFIGURE_TIMEOUT_MS * Math.pow(2, this.configureTimeoutCount), REFRESH_TIMEOUT_MS);
606+
if (this.configureTimeoutCount > 0) {
607+
this.outputChannel.info(
608+
`[pet] configure: Using extended timeout of ${timeoutMs}ms (retry ${this.configureTimeoutCount})`,
609+
);
610+
}
603611
try {
604-
await sendRequestWithTimeout(this.connection, 'configure', options, CONFIGURE_TIMEOUT_MS);
612+
await sendRequestWithTimeout(this.connection, 'configure', options, timeoutMs);
605613
// Only cache after success so failed/timed-out calls will retry
606614
this.lastConfiguration = options;
607615
this.configureTimeoutCount = 0;
608616
} catch (ex) {
617+
// Clear cached config so the next call retries instead of short-circuiting via configurationEquals
618+
this.lastConfiguration = undefined;
609619
if (ex instanceof RpcTimeoutError) {
610620
this.configureTimeoutCount++;
611621
if (this.configureTimeoutCount >= MAX_CONFIGURE_TIMEOUTS_BEFORE_KILL) {

0 commit comments

Comments
 (0)