From e421414b8a8ff9a5e4ee015ce24aac0e976428a3 Mon Sep 17 00:00:00 2001 From: Sander Declerck Date: Fri, 5 Dec 2025 12:12:22 +0100 Subject: [PATCH] Don't repeatedly call isImdsEndpoint --- .../safe-chain/src/registryProxy/isImdsEndpoint.js | 2 +- .../src/registryProxy/tunnelRequestHandler.js | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/packages/safe-chain/src/registryProxy/isImdsEndpoint.js b/packages/safe-chain/src/registryProxy/isImdsEndpoint.js index 2bde02a..deccf10 100644 --- a/packages/safe-chain/src/registryProxy/isImdsEndpoint.js +++ b/packages/safe-chain/src/registryProxy/isImdsEndpoint.js @@ -5,7 +5,7 @@ const imdsEndpoints = [ "metadata.google.internal", "metadata.goog", - "169.254.169.254", + "169.254.169.254", // AWS, Azure, Oracle Cloud, GCP ]; export function isImdsEndpoint(/** @type {string} */ host) { diff --git a/packages/safe-chain/src/registryProxy/tunnelRequestHandler.js b/packages/safe-chain/src/registryProxy/tunnelRequestHandler.js index 9288ec3..b97799b 100644 --- a/packages/safe-chain/src/registryProxy/tunnelRequestHandler.js +++ b/packages/safe-chain/src/registryProxy/tunnelRequestHandler.js @@ -76,13 +76,17 @@ function tunnelRequestToDestination(req, clientSocket, head) { serverSocket.on("timeout", () => { timedoutEndpoints.push(hostname); // Suppress error logging for IMDS endpoints - timeouts are expected when not in cloud - if (isImdsEndpoint(hostname)) { + if (isImds) { ui.writeVerbose( - `Safe-chain: connect to ${hostname}:${port || 443} timed out after ${connectTimeout}ms` + `Safe-chain: connect to ${hostname}:${ + port || 443 + } timed out after ${connectTimeout}ms` ); } else { ui.writeError( - `Safe-chain: connect to ${hostname}:${port || 443} timed out after ${connectTimeout}ms` + `Safe-chain: connect to ${hostname}:${ + port || 443 + } timed out after ${connectTimeout}ms` ); } serverSocket.destroy(); // Clean up socket to prevent event loop hanging @@ -98,7 +102,7 @@ function tunnelRequestToDestination(req, clientSocket, head) { }); serverSocket.on("error", (err) => { - if (isImdsEndpoint(hostname)) { + if (isImds) { ui.writeVerbose( `Safe-chain: error connecting to ${hostname}:${port} - ${err.message}` );