File tree Expand file tree Collapse file tree 1 file changed +7
-0
lines changed
Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Original file line number Diff line number Diff line change @@ -507,6 +507,13 @@ export class BaseAnthropic {
507507 if ( isAbortError ( response ) ) {
508508 throw new Errors . APIConnectionTimeoutError ( ) ;
509509 }
510+ // detect native connection timeout errors
511+ // deno throws "TypeError: error sending request for url (https://example/): client error (Connect): tcp connect error: Operation timed out (os error 60): Operation timed out (os error 60)"
512+ // undici throws "TypeError: fetch failed" with cause "ConnectTimeoutError: Connect Timeout Error (attempted address: example:443, timeout: 1ms)"
513+ // others do not provide enough information to distinguish timeouts from other connection errors
514+ if ( / t i m e d ? ? o u t / i. test ( String ( response ) + ( 'cause' in response ? String ( response . cause ) : '' ) ) ) {
515+ throw new Errors . APIConnectionTimeoutError ( ) ;
516+ }
510517 throw new Errors . APIConnectionError ( { cause : response } ) ;
511518 }
512519
You can’t perform that action at this time.
0 commit comments