From faa14fa91de6fbb71372559e6c0f1740d3347e3b Mon Sep 17 00:00:00 2001 From: Girish Ramakrishnan Date: Tue, 18 Feb 2025 12:41:30 +0100 Subject: [PATCH] superagent: retry in graphs logic to workaround node socket issue https://github.com/nodejs/undici/issues/3492 --- src/graphs.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/graphs.js b/src/graphs.js index b32d3a2d2..8bd16bf64 100644 --- a/src/graphs.js +++ b/src/graphs.js @@ -61,7 +61,9 @@ async function getContainerStats(name, fromMinutes, noNullPoints) { noNullPoints: !!noNullPoints }; - const [error, response] = await safe(superagent.get(graphiteUrl).query(query).timeout(30 * 1000).ok(() => true)); + // the retry() is needed because there is a node/fetch bug that a closed socket is reused when making a request to the same endpoint many times + // https://github.com/nodejs/undici/issues/3492 + const [error, response] = await safe(superagent.get(graphiteUrl).query(query).timeout(30 * 1000).retry(3).ok(() => true)); if (error) throw new BoxError(BoxError.NETWORK_ERROR, error); if (response.status !== 200) throw new BoxError(BoxError.EXTERNAL_ERROR, `Unknown error with ${target}: ${response.status} ${response.text}`);