Update error handling during TLS connection

This commit is contained in:
trevor-signal 2024-08-07 14:37:49 -04:00 committed by GitHub
parent 8719b296cf
commit 03d68c3137
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 16 additions and 27 deletions

View file

@ -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');