superagent: retry in graphs logic to workaround node socket issue

https://github.com/nodejs/undici/issues/3492
This commit is contained in:
Girish Ramakrishnan
2025-02-18 12:41:30 +01:00
parent 85dced9cd1
commit faa14fa91d
+3 -1
View File
@@ -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}`);