File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed
packages/node-http-handler/src Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change 1+ /**
2+ * Node.js system error codes that indicate timeout.
3+ */
4+ export const NODEJS_TIMEOUT_ERROR_CODES = [ "ECONNRESET" , "EPIPE" , "ETIMEDOUT" ] ;
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import { HttpHandlerOptions } from "@aws-sdk/types";
44import { Agent as hAgent , request as hRequest } from "http" ;
55import { Agent as hsAgent , request as hsRequest , RequestOptions } from "https" ;
66
7+ import { NODEJS_TIMEOUT_ERROR_CODES } from "./constants" ;
78import { getTransformedHeaders } from "./get-transformed-headers" ;
89import { setConnectionTimeout } from "./set-connection-timeout" ;
910import { setSocketTimeout } from "./set-socket-timeout" ;
@@ -83,7 +84,13 @@ export class NodeHttpHandler implements HttpHandler {
8384 resolve ( { response : httpResponse } ) ;
8485 } ) ;
8586
86- req . on ( "error" , reject ) ;
87+ req . on ( "error" , ( err : Error ) => {
88+ if ( NODEJS_TIMEOUT_ERROR_CODES . includes ( ( err as any ) . code ) ) {
89+ reject ( Object . assign ( err , { name : "TimeoutError" } ) ) ;
90+ } else {
91+ reject ( err ) ;
92+ }
93+ } ) ;
8794
8895 // wire-up any timeout logic
8996 setConnectionTimeout ( req , reject , this . connectionTimeout ) ;
You can’t perform that action at this time.
0 commit comments