forked from Shared/esg
base url dev + some error handling
This commit is contained in:
@@ -70,7 +70,7 @@ async function bootstrap(): Promise<void> {
|
|||||||
)
|
)
|
||||||
.setVersion('1.0')
|
.setVersion('1.0')
|
||||||
.addServer("http://localhost:8085")
|
.addServer("http://localhost:8085")
|
||||||
.addServer("http://192.168.20.22:8085");
|
.addServer(process.env.BASE_URL_DEV + "")
|
||||||
|
|
||||||
if (clientUrl) {
|
if (clientUrl) {
|
||||||
documentBuilder.addServer(clientUrl);
|
documentBuilder.addServer(clientUrl);
|
||||||
|
|||||||
@@ -119,10 +119,31 @@ export abstract class BaseProvider<TRequest = unknown, TResponse = unknown>
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected isRetryable(error: unknown): boolean {
|
protected isRetryable(error: unknown): boolean {
|
||||||
if (error && typeof error === 'object' && 'code' in error) {
|
if (!error || typeof error !== 'object') return false;
|
||||||
|
|
||||||
|
// Network-level transient errors
|
||||||
|
if ('code' in error) {
|
||||||
const code = (error as { code?: string }).code;
|
const code = (error as { code?: string }).code;
|
||||||
return code === 'ETIMEDOUT' || code === 'ECONNABORTED' || code === 'ECONNRESET';
|
if (code === 'ETIMEDOUT' || code === 'ECONNABORTED' || code === 'ECONNRESET') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// HTTP errors that indicate provider unavailability
|
||||||
|
if ('response' in error) {
|
||||||
|
const status = (error as { response?: { status?: number } }).response?.status;
|
||||||
|
if (typeof status === 'number') {
|
||||||
|
if (
|
||||||
|
status === 408 || // Request Timeout — provider didn't answer in time
|
||||||
|
status === 429 || // Too Many Requests — provider rate-limited us
|
||||||
|
status === 499 || // Client Closed Request — provider hung up
|
||||||
|
(status >= 500 && status < 600) // 5xx server errors
|
||||||
|
) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user