Skip to content

Commit 877bbb5

Browse files
committed
refactor: extract hardcoded constants to constants file
- Create autoDebug/constants.ts with retry configuration constants - Replace hardcoded values in client.ts with imported constants - Use camelCase naming convention for ESLint compliance - Address reviewer feedback for better maintainability Constants extracted: - maxAttempts: 5 - initialDelayMs: 1000 - maxDelayMs: 10000 - backoffMultiplier: 2
1 parent 0465f54 commit 877bbb5

File tree

2 files changed

+34
-4
lines changed

2 files changed

+34
-4
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*!
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
/**
7+
* Constants for AutoDebug feature retry configuration
8+
*/
9+
export const autoDebugRetryConfig = {
10+
/**
11+
* Maximum number of attempts to connect AutoDebug feature to language client
12+
*/
13+
MAXAttempts: 5,
14+
15+
/**
16+
* Initial delay in milliseconds before first retry attempt
17+
*/
18+
initialDelayMs: 1000,
19+
20+
/**
21+
* Maximum delay in milliseconds between retry attempts
22+
*/
23+
maxDelayMs: 10000,
24+
25+
/**
26+
* Multiplier for exponential backoff calculation
27+
*/
28+
backoffMultiplier: 2,
29+
} as const

packages/amazonq/src/lsp/client.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ import { InlineTutorialAnnotation } from '../app/inline/tutorials/inlineTutorial
5454
import { InlineChatTutorialAnnotation } from '../app/inline/tutorials/inlineChatTutorialAnnotation'
5555
import { codeReviewInChat } from '../app/amazonqScan/models/constants'
5656
import { AutoDebugFeature } from '../autoDebug'
57+
import { autoDebugRetryConfig } from '../autoDebug/constants'
5758

5859
// Module-level registry for AutoDebug feature
5960
let registeredAutoDebugFeature: AutoDebugFeature | undefined
@@ -418,10 +419,10 @@ async function onLanguageServerReady(
418419
getLogger('amazonqLsp').debug('AutoDebug feature connected successfully')
419420
},
420421
{
421-
maxAttempts: 5,
422-
initialDelayMs: 1000,
423-
maxDelayMs: 10000,
424-
backoffMultiplier: 2,
422+
maxAttempts: autoDebugRetryConfig.maxAttempts,
423+
initialDelayMs: autoDebugRetryConfig.initialDelayMs,
424+
maxDelayMs: autoDebugRetryConfig.maxDelayMs,
425+
backoffMultiplier: autoDebugRetryConfig.backoffMultiplier,
425426
onRetry: (attempt, error) => {
426427
getLogger('amazonqLsp').debug(
427428
'AutoDebug connection attempt %d failed: %s. Retrying...',

0 commit comments

Comments
 (0)