File tree Expand file tree Collapse file tree 2 files changed +8
-2
lines changed
packages/service-error-classification/src Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -135,6 +135,12 @@ describe("isTransientError", () => {
135135 checkForErrorType ( isTransientError , { cause : { name } } , true ) ;
136136 } ) ;
137137 } ) ;
138+
139+ it ( "should limit recursion to 10 depth" , ( ) => {
140+ const error = { cause : null } as SdkError ;
141+ error . cause = error ;
142+ checkForErrorType ( isTransientError , { cause : error } , false ) ;
143+ } ) ;
138144} ) ;
139145
140146describe ( "isServerError" , ( ) => {
Original file line number Diff line number Diff line change @@ -31,12 +31,12 @@ export const isThrottlingError = (error: SdkError) =>
3131 * cause where the NodeHttpHandler does not decorate the Error with
3232 * the name "TimeoutError" to be checked by the TRANSIENT_ERROR_CODES condition.
3333 */
34- export const isTransientError = ( error : SdkError ) =>
34+ export const isTransientError = ( error : SdkError , depth = 0 ) =>
3535 isClockSkewCorrectedError ( error ) ||
3636 TRANSIENT_ERROR_CODES . includes ( error . name ) ||
3737 NODEJS_TIMEOUT_ERROR_CODES . includes ( ( error as { code ?: string } ) ?. code || "" ) ||
3838 TRANSIENT_ERROR_STATUS_CODES . includes ( error . $metadata ?. httpStatusCode || 0 ) ||
39- ( error . cause !== undefined && isTransientError ( error . cause ) ) ;
39+ ( error . cause !== undefined && depth <= 10 && isTransientError ( error . cause , depth + 1 ) ) ;
4040
4141export const isServerError = ( error : SdkError ) => {
4242 if ( error . $metadata ?. httpStatusCode !== undefined ) {
You can’t perform that action at this time.
0 commit comments