fix(slurm): add default 30s timeout to HTTP client

Replaces http.DefaultClient with a client that has a 30s timeout to prevent indefinite hangs when the Slurm REST API is unresponsive.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
dailz
2026-04-10 09:25:35 +08:00
parent 1359730300
commit c070dd8abc
4 changed files with 13 additions and 8 deletions

View File

@@ -24,6 +24,8 @@ func defaultClientConfig() *clientConfig {
}
}
const defaultHTTPTimeout = 30 * time.Second
// WithJWTKey specifies the path to the JWT key file.
func WithJWTKey(path string) ClientOption {
return func(c *clientConfig) error {
@@ -89,11 +91,12 @@ func NewClientWithOpts(baseURL string, opts ...ClientOption) (*Client, error) {
}
tr := NewJWTAuthTransport(cfg.username, key, transportOpts...)
httpClient = tr.Client()
httpClient = &http.Client{
Transport: tr,
Timeout: defaultHTTPTimeout,
}
} else if cfg.httpClient != nil {
httpClient = cfg.httpClient
} else {
httpClient = http.DefaultClient
}
return NewClient(baseURL, httpClient)