mirror of
https://github.com/dolthub/dolt.git
synced 2026-02-12 02:58:53 -06:00
JS: add http idle timeout
Node's http.ClientRequest supports setting an idle-timeout, so just go ahead and do that. Setting to 2 minutes to match Go. Fixes #1414
This commit is contained in:
@@ -33,6 +33,13 @@ function fetch<T>(url: string, f: (buf: Buffer) => T, options: FetchOptions = {}
|
||||
req.on('error', err => {
|
||||
reject(err);
|
||||
});
|
||||
// Set an idle-timeout of 2 minutes. The contract requires us to manually abort the connection,
|
||||
// then catch that event and report an error.
|
||||
req.setTimeout(2 * 60 * 1000, () => req.abort());
|
||||
req.on('abort', () => {
|
||||
reject(new Error('HTTP request timed out'));
|
||||
});
|
||||
|
||||
if (options.body) {
|
||||
req.write(options.body);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user