better agent fetch logging

This commit is contained in:
Dallin Romney 2025-06-17 11:28:31 -07:00
parent 8245e4fc72
commit deca888900

View file

@ -12,7 +12,8 @@ export async function getAgentOptions(
const TIMEOUT = 7200; // 7200 seconds = 2 hours
const timeout = (requestOptions?.timeout ?? TIMEOUT) * 1000; // measured in ms
const ca = await CertsCache.getInstance().getCa(requestOptions?.caBundlePath);
const certsCache = CertsCache.getInstance();
const ca = await certsCache.getCa(requestOptions?.caBundlePath);
const agentOptions: { [key: string]: any } = {
ca,
@ -23,19 +24,6 @@ export async function getAgentOptions(
keepAliveMsecs: timeout,
};
if (process.env.VERBOSE_FETCH) {
console.log("=== CERTIFICATE CONFIGURATION ===");
console.log(`Number of CA certificates: ${ca.length}`);
console.log(
`Global agent CA certificates: ${globalAgent.options.ca ? "Present" : "Not present"}`,
);
console.log(
`Custom certificates provided: ${customCerts?.length ? "Yes" : "No"}`,
);
console.log(`rejectUnauthorized: ${agentOptions.rejectUnauthorized}`);
console.log("================================");
}
// Handle ClientCertificateOptions
if (requestOptions?.clientCertificate) {
const { cert, key, passphrase } = requestOptions.clientCertificate;
@ -48,5 +36,21 @@ export async function getAgentOptions(
}
}
if (process.env.VERBOSE_FETCH) {
console.log(
`Fetch agent: rejectUnauthorized/verifySsl: ${agentOptions.rejectUnauthorized ?? "not set (defaulting to true)"}`,
);
console.log(`Fetch agent options:`);
console.log(
`\tTimeout (sessionTimeout/keepAliveMsecs): ${agentOptions.timeout}`,
);
console.log(`\tTotal CA certs: ${ca.length}`);
console.log(`\tGlobal/Root CA certs: ${certsCache.fixedCa.length}`);
console.log(`\tCustom CA certs: ${ca.length - certsCache.fixedCa.length}`);
console.log(
`\tClient certificate: ${requestOptions?.clientCertificate ? "Yes" : "No"}`,
);
}
return agentOptions;
}