@@ -20,6 +20,28 @@ export const isClockSkewError = (error: SdkError) => CLOCK_SKEW_ERROR_CODES.incl
2020 */
2121export const isClockSkewCorrectedError = ( error : SdkError ) => error . $metadata ?. clockSkewCorrected ;
2222
23+ /**
24+ *
25+ * @internal
26+ */
27+ export const isBrowserNetworkError = ( error : SdkError ) => {
28+ const errorMessages = new Set ( [
29+ "Failed to fetch" , // Chrome
30+ "NetworkError when attempting to fetch resource" , // Firefox
31+ "The Internet connection appears to be offline" , // Safari 16
32+ "Load failed" , // Safari 17+
33+ "Network request failed" , // `cross-fetch`
34+ ] ) ;
35+
36+ const isValid = error && error instanceof TypeError ;
37+
38+ if ( ! isValid ) {
39+ return false ;
40+ }
41+
42+ return errorMessages . has ( error . message ) ;
43+ } ;
44+
2345export const isThrottlingError = ( error : SdkError ) =>
2446 error . $metadata ?. httpStatusCode === 429 ||
2547 THROTTLING_ERROR_CODES . includes ( error . name ) ||
@@ -36,6 +58,7 @@ export const isTransientError = (error: SdkError, depth = 0): boolean =>
3658 TRANSIENT_ERROR_CODES . includes ( error . name ) ||
3759 NODEJS_TIMEOUT_ERROR_CODES . includes ( ( error as { code ?: string } ) ?. code || "" ) ||
3860 TRANSIENT_ERROR_STATUS_CODES . includes ( error . $metadata ?. httpStatusCode || 0 ) ||
61+ isBrowserNetworkError ( error ) ||
3962 ( error . cause !== undefined && depth <= 10 && isTransientError ( error . cause , depth + 1 ) ) ;
4063
4164export const isServerError = ( error : SdkError ) => {
0 commit comments