fix: improve RADIUS client error handling and socket cleanup (#6783)

Co-authored-by: GitTensor Miner <miner@gittensor.io>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
dive2tech
2026-01-22 12:57:28 +00:00
committed by GitHub
co-authored by GitTensor Miner autofix-ci[bot]
parent a38c6dea25
commit 236d74238c
2 changed files with 43 additions and 13 deletions
+12 -2
View File
@@ -356,10 +356,20 @@ exports.radius = function (
],
})
.catch((error) => {
// Preserve error stack trace and provide better context
if (error.response?.code) {
throw Error(error.response.code);
const radiusError = new Error(`RADIUS ${error.response.code} from ${hostname}:${port}`);
radiusError.response = error.response;
radiusError.originalError = error;
throw radiusError;
} else {
throw Error(error.message);
// Preserve original error message and stack trace
const enhancedError = new Error(
`RADIUS authentication failed for ${hostname}:${port}: ${error.message}`
);
enhancedError.originalError = error;
enhancedError.stack = error.stack || enhancedError.stack;
throw enhancedError;
}
});
};