Skip checks for non-URLs for now

This commit is contained in:
Michael B. Gale
2026-02-11 18:02:24 +00:00
parent 2b5b614c85
commit efb92e2714
3 changed files with 56 additions and 24 deletions
+13 -10
View File
@@ -121728,10 +121728,10 @@ var NetworkReachabilityBackend = class {
this.agent = new import_https_proxy_agent.HttpsProxyAgent(`http://${proxy.host}:${proxy.port}`);
}
agent;
async checkConnection(registry) {
async checkConnection(url) {
return new Promise((resolve2, reject) => {
const req = https.request(
getAddressString(registry),
url,
{
agent: this.agent,
method: "HEAD",
@@ -121768,21 +121768,24 @@ async function checkConnections(logger, proxy, backend) {
}
for (const registry of proxy.registries) {
const address = getAddressString(registry);
try {
logger.debug(`Testing connection to ${address}...`);
const statusCode = await backend.checkConnection(registry);
const url = URL.parse(address);
if (url === null) {
logger.info(
`Successfully tested connection to ${address} (${statusCode})`
`Skipping check for ${address} since it is not a valid URL.`
);
continue;
}
try {
logger.debug(`Testing connection to ${url}...`);
const statusCode = await backend.checkConnection(url);
logger.info(`Successfully tested connection to ${url} (${statusCode})`);
result.add(registry);
} catch (e) {
if (e instanceof ReachabilityError && e.statusCode !== void 0) {
logger.error(
`Connection test to ${address} failed. (${e.statusCode})`
);
logger.error(`Connection test to ${url} failed. (${e.statusCode})`);
} else {
logger.error(
`Connection test to ${address} failed: ${getErrorMessage(e)}`
`Connection test to ${url} failed: ${getErrorMessage(e)}`
);
}
}