-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: print more socket info on UND_ERR_CONNECT_TIMEOUT error (#477)
- Loading branch information
Showing
20 changed files
with
187 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import type { RawResponseWithMeta, SocketInfo } from './Response.js'; | ||
import type { IncomingHttpHeaders } from './IncomingHttpHeaders.js'; | ||
|
||
// need to support ES2021 | ||
interface ErrorOptions { | ||
cause?: Error; | ||
} | ||
|
||
export class HttpClientRequestError extends Error { | ||
status?: number; | ||
headers?: IncomingHttpHeaders; | ||
socket?: SocketInfo; | ||
res?: RawResponseWithMeta; | ||
} | ||
|
||
export class HttpClientRequestTimeoutError extends HttpClientRequestError { | ||
constructor(timeout: number, options: ErrorOptions) { | ||
const message = `Request timeout for ${timeout} ms`; | ||
super(message, options); | ||
this.name = this.constructor.name; | ||
Error.captureStackTrace(this, this.constructor); | ||
} | ||
} | ||
|
||
export class HttpClientConnectTimeoutError extends HttpClientRequestError { | ||
code: string; | ||
|
||
constructor(message: string, code: string, options: ErrorOptions) { | ||
super(message, options); | ||
this.name = this.constructor.name; | ||
this.code = code; | ||
Error.captureStackTrace(this, this.constructor); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { RequestURL, RequestOptions2, RequestOptions } from 'urllib'; | ||
import { HttpClientResponse } from 'urllib'; | ||
import urllib from 'urllib'; | ||
import * as urllib2 from 'urllib'; | ||
|
||
async function request(url: RequestURL, options: RequestOptions): Promise<HttpClientResponse> { | ||
return await urllib.request(url, options); | ||
} | ||
|
||
async function request2(url: RequestURL, options: RequestOptions2): Promise<HttpClientResponse> { | ||
return await urllib2.curl(url, options); | ||
} | ||
|
||
console.log(request, request2); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"name": "ts-cjs-demo", | ||
"scripts": { | ||
"build": "tsc && node hello.js" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"compilerOptions": { | ||
"strict": true, | ||
"target": "ES2021", | ||
"module": "CommonJS", | ||
"moduleResolution": "Node", | ||
"baseUrl": "./", | ||
"paths": { | ||
"urllib": ["../../.."] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.