-
Notifications
You must be signed in to change notification settings - Fork 1
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
feat(backend): backend error handling strategy #89
Merged
Merged
Changes from 10 commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
5d3a8e7
feat(backend): update chatSync calls to use structured message format…
Sma1lboy 52d587a
refactor(backend): simplify chat input type and clean up unused embed…
Sma1lboy 47d7e43
feat(backend): enhance test utilities and improve markdown output for…
Sma1lboy d5bf1b9
chore: update documentation for improved clarity and consistency
Sma1lboy 89fd2f3
[autofix.ci] apply automated fixes
autofix-ci[bot] 88d79db
fix: deleting useless embedding module and adding tests for openai em…
NarwhalChen 1ff5a5d
feat: adding retryable error handler
NarwhalChen ebc2daa
Merge branch 'main' of https://github.com/Sma1lboy/codefox into featu…
NarwhalChen 169556e
feat: merging useless promise set and updating ux handler to newet ve…
NarwhalChen 18b12ad
[autofix.ci] apply automated fixes
autofix-ci[bot] 269d740
fix: Undelete false delete during merge
NarwhalChen ce77412
Merge branch 'feature-backend-error-handling-strategy' of https://git…
NarwhalChen 988b0ba
Merge branch 'main' of https://github.com/Sma1lboy/codefox into featu…
NarwhalChen bbba977
feat: deleting repeat retry in file arch
NarwhalChen 7c4d783
feat: adding retryable error and non retryable error for retry handler
NarwhalChen 5ed11e7
[autofix.ci] apply automated fixes
autofix-ci[bot] 2daed38
feat: adapting all handlers to retry handler
NarwhalChen 3296a80
Merge branch 'feature-backend-error-handling-strategy' of https://git…
NarwhalChen 317c690
[autofix.ci] apply automated fixes
autofix-ci[bot] bb7b3d7
feat: support detail error in handler
NarwhalChen 2d2bb8d
[autofix.ci] apply automated fixes
autofix-ci[bot] cf221cb
feat: removing useless error
NarwhalChen 370a453
fix: fixing wrong version of fullstack test
NarwhalChen 4718272
[autofix.ci] apply automated fixes
autofix-ci[bot] 0654d78
fix: update prompt handling and improve regex for section extraction
Sma1lboy 25ac7d8
fix: add handling for ResponseParsingError in retry logic
Sma1lboy 3f3dc91
refactor: remove unused error classes and improve error handling in r…
Sma1lboy 85c09f1
refactor: introduce base error classes for retryable and non-retryabl…
Sma1lboy 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
There are no files selected for viewing
This file contains 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
12 changes: 0 additions & 12 deletions
12
backend/src/build-system/__tests__/test.model-provider.spec.ts
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains 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
This file contains 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,59 @@ | ||
import { Logger } from '@nestjs/common'; | ||
|
||
export class RetryHandler { | ||
private readonly logger = new Logger(RetryHandler.name); | ||
private static instance: RetryHandler; | ||
private retryCounts: Map<string, number> = new Map(); | ||
public static getInstance() { | ||
if (this.instance) return this.instance; | ||
return new RetryHandler(); | ||
} | ||
async retryMethod( | ||
error: Error, | ||
upperMethod: (...args: any[]) => void, | ||
args: any[], | ||
): Promise<void> { | ||
const errorName = error.name; | ||
let retryCount = this.retryCounts.get(errorName) || 0; | ||
const isRetrying = this.retryCounts.has(errorName); | ||
let res; | ||
switch (errorName) { | ||
case 'GeneratedTagError': | ||
case 'TimeoutError': | ||
this.logger.warn( | ||
`Retryable error occurred: ${error.message}. Retrying...`, | ||
); | ||
if (!isRetrying) this.retryCounts.set(errorName, 0); | ||
else | ||
this.retryCounts.set(errorName, this.retryCounts.get(errorName) + 1); | ||
while (retryCount < 3) { | ||
try { | ||
this.logger.log(`retryCount: ${retryCount}`); | ||
res = await upperMethod(...args); | ||
} catch (e) { | ||
if (e.name === errorName) { | ||
retryCount++; | ||
this.retryCounts.set(errorName, retryCount); | ||
this.logger.warn( | ||
`Retryable error occurred: ${e.name}: ${e.message}. Retrying attempt ${retryCount}...`, | ||
); | ||
} else { | ||
this.logger.error( | ||
`Non-retryable error occurred: ${e.name}: ${e.message}. Terminating process.`, | ||
); | ||
throw e; | ||
} | ||
} | ||
} | ||
this.retryCounts.delete(errorName); | ||
if (res) return res; | ||
this.logger.error('Max retry attempts reached. Terminating process.'); | ||
throw new Error('Max retry attempts reached'); | ||
default: | ||
this.logger.error( | ||
`Non-retryable error occurred: ${error.name}: ${error.message}. Terminating process.`, | ||
); | ||
throw error; | ||
} | ||
} | ||
} |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove this change please, or put all into test-utils