-
Notifications
You must be signed in to change notification settings - Fork 38
fix: graduate PET configure timeout to avoid killing process prematurely (Fixes #1274) #1275
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+222
−13
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
d7a192e
fix: graduate PET configure timeout to avoid killing process prematur…
karthiknadig 91cb0dc
fix: add exponential backoff to configure timeout, set Error.name, cl…
karthiknadig b2135ec
test: add unit tests for RpcTimeoutError and configure timeout backof…
karthiknadig 49a4def
fix: reset configureTimeoutCount on non-timeout errors, extract Confi…
karthiknadig File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
119 changes: 119 additions & 0 deletions
119
src/test/managers/common/nativePythonFinder.configureTimeout.unit.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,119 @@ | ||
| import assert from 'node:assert'; | ||
| import { | ||
| ConfigureRetryState, | ||
| RpcTimeoutError, | ||
| getConfigureTimeoutMs, | ||
| } from '../../../managers/common/nativePythonFinder'; | ||
|
|
||
| suite('RpcTimeoutError', () => { | ||
| test('has correct name property', () => { | ||
| const error = new RpcTimeoutError('configure', 30000); | ||
| assert.strictEqual(error.name, 'RpcTimeoutError'); | ||
| }); | ||
|
|
||
| test('has correct method property', () => { | ||
| const error = new RpcTimeoutError('configure', 30000); | ||
| assert.strictEqual(error.method, 'configure'); | ||
| }); | ||
|
|
||
| test('message includes method name and timeout', () => { | ||
| const error = new RpcTimeoutError('resolve', 5000); | ||
| assert.strictEqual(error.message, "Request 'resolve' timed out after 5000ms"); | ||
| }); | ||
|
|
||
| test('is instanceof Error', () => { | ||
| const error = new RpcTimeoutError('configure', 30000); | ||
| assert.ok(error instanceof Error); | ||
| assert.ok(error instanceof RpcTimeoutError); | ||
| }); | ||
| }); | ||
|
|
||
| suite('getConfigureTimeoutMs', () => { | ||
| test('returns base timeout (30s) on first attempt', () => { | ||
| assert.strictEqual(getConfigureTimeoutMs(0), 30_000); | ||
| }); | ||
|
|
||
| test('doubles timeout on first retry (60s)', () => { | ||
| assert.strictEqual(getConfigureTimeoutMs(1), 60_000); | ||
| }); | ||
|
|
||
| test('doubles again on second retry (120s)', () => { | ||
| assert.strictEqual(getConfigureTimeoutMs(2), 120_000); | ||
| }); | ||
|
|
||
| test('caps at REFRESH_TIMEOUT_MS (120s) for higher retries', () => { | ||
| // 30_000 * 2^3 = 240_000, but capped at 120_000 | ||
| assert.strictEqual(getConfigureTimeoutMs(3), 120_000); | ||
| assert.strictEqual(getConfigureTimeoutMs(10), 120_000); | ||
| }); | ||
| }); | ||
karthiknadig marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| suite('ConfigureRetryState', () => { | ||
| let state: ConfigureRetryState; | ||
|
|
||
| setup(() => { | ||
| state = new ConfigureRetryState(); | ||
| }); | ||
|
|
||
| test('initial timeout count is 0', () => { | ||
| assert.strictEqual(state.timeoutCount, 0); | ||
| }); | ||
|
|
||
| test('initial timeout is base (30s)', () => { | ||
| assert.strictEqual(state.getTimeoutMs(), 30_000); | ||
| }); | ||
|
|
||
| test('onSuccess resets timeout count', () => { | ||
| state.onTimeout(); // count = 1 | ||
| state.onSuccess(); | ||
| assert.strictEqual(state.timeoutCount, 0); | ||
| assert.strictEqual(state.getTimeoutMs(), 30_000); | ||
| }); | ||
|
|
||
| test('first timeout does not kill (returns false)', () => { | ||
| const shouldKill = state.onTimeout(); | ||
| assert.strictEqual(shouldKill, false); | ||
| assert.strictEqual(state.timeoutCount, 1); | ||
| }); | ||
|
|
||
| test('first timeout increases next timeout to 60s', () => { | ||
| state.onTimeout(); | ||
| assert.strictEqual(state.getTimeoutMs(), 60_000); | ||
| }); | ||
|
|
||
| test('second consecutive timeout kills (returns true)', () => { | ||
| state.onTimeout(); // count = 1 | ||
| const shouldKill = state.onTimeout(); // count = 2 → kill → reset to 0 | ||
| assert.strictEqual(shouldKill, true); | ||
| assert.strictEqual(state.timeoutCount, 0); // Reset after kill | ||
| }); | ||
|
|
||
| test('non-timeout error resets counter via reset()', () => { | ||
| state.onTimeout(); // count = 1 | ||
| state.reset(); // simulates non-timeout error | ||
| assert.strictEqual(state.timeoutCount, 0); | ||
| // Next timeout should not trigger kill | ||
| const shouldKill = state.onTimeout(); | ||
| assert.strictEqual(shouldKill, false); | ||
| }); | ||
|
|
||
| test('interleaved non-timeout error prevents premature kill', () => { | ||
| state.onTimeout(); // count = 1 | ||
| state.reset(); // non-timeout error resets | ||
| state.onTimeout(); // count = 1 again (not 2) | ||
| assert.strictEqual(state.timeoutCount, 1); | ||
| // Still shouldn't kill — only 1 consecutive timeout | ||
| assert.strictEqual(state.getTimeoutMs(), 60_000); | ||
| }); | ||
|
|
||
| test('reset after kill allows fresh retry cycle', () => { | ||
| state.onTimeout(); | ||
| state.onTimeout(); // kill → reset | ||
| // Counter was reset by onTimeout when it returned true | ||
| assert.strictEqual(state.timeoutCount, 0); | ||
| assert.strictEqual(state.getTimeoutMs(), 30_000); | ||
| // First timeout of new cycle should not kill | ||
| const shouldKill = state.onTimeout(); | ||
| assert.strictEqual(shouldKill, false); | ||
| }); | ||
| }); | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.