Add tests for: not shortcircuiting timeout on imds endpoint.

This commit is contained in:
Sander Declerck 2025-12-09 15:46:37 +01:00
parent afc68618c6
commit 40650e7912
No known key found for this signature in database
3 changed files with 94 additions and 28 deletions

View file

@ -0,0 +1,13 @@
import { isImdsEndpoint } from "./isImdsEndpoint.js";
/**
* Returns appropriate connection timeout for a host.
* - IMDS endpoints: 3s (fail fast when outside cloud, reduce 5min delay to ~20s)
* - Other endpoints: 30s (allow for slow networks while preventing indefinite hangs)
*/
export function getConnectTimeout(/** @type {string} */ host) {
if (isImdsEndpoint(host)) {
return 3000;
}
return 30000;
}