Update error handling during TLS connection
This commit is contained in:
parent
8719b296cf
commit
03d68c3137
2 changed files with 16 additions and 27 deletions
|
@ -1,17 +0,0 @@
|
|||
diff --git a/node_modules/@types/node/tls.d.ts b/node_modules/@types/node/tls.d.ts
|
||||
index 2c55eb9..a594969 100755
|
||||
--- a/node_modules/@types/node/tls.d.ts
|
||||
+++ b/node_modules/@types/node/tls.d.ts
|
||||
@@ -621,6 +621,12 @@ declare module 'tls' {
|
||||
* `identity` must use UTF-8 encoding.
|
||||
*/
|
||||
pskCallback?(hint: string | null): PSKCallbackNegotation | null;
|
||||
+
|
||||
+ /* Node.js documentation says:
|
||||
+ * "...: Any socket.connect() option not already listed."
|
||||
+ * and "signal" is one of them.
|
||||
+ */
|
||||
+ signal?: AbortSignal;
|
||||
}
|
||||
/**
|
||||
* Accepts encrypted connections using TLS or SSL.
|
|
@ -145,16 +145,22 @@ export async function happyEyeballs({
|
|||
v6Attempts += 1;
|
||||
}
|
||||
|
||||
const socket = await pTimeout(
|
||||
connect({
|
||||
address: addr.address,
|
||||
port,
|
||||
tlsOptions,
|
||||
abortSignal: abortController.signal,
|
||||
}),
|
||||
CONNECT_TIMEOUT_MS,
|
||||
'createHTTPSAgent.connect: connection timed out'
|
||||
);
|
||||
let socket: net.Socket;
|
||||
try {
|
||||
socket = await pTimeout(
|
||||
connect({
|
||||
address: addr.address,
|
||||
port,
|
||||
tlsOptions,
|
||||
abortSignal: abortController.signal,
|
||||
}),
|
||||
CONNECT_TIMEOUT_MS,
|
||||
'createHTTPSAgent.connect: connection timed out'
|
||||
);
|
||||
} catch (error) {
|
||||
abortController.abort();
|
||||
throw error;
|
||||
}
|
||||
|
||||
if (abortController.signal.aborted) {
|
||||
throw new Error('Aborted');
|
||||
|
|
Loading…
Reference in a new issue