7 lines
270 B
JavaScript
7 lines
270 B
JavaScript
|
export const setSocketTimeout = (request, reject, timeoutInMs = 0) => {
|
||
|
request.setTimeout(timeoutInMs, () => {
|
||
|
request.destroy();
|
||
|
reject(Object.assign(new Error(`Connection timed out after ${timeoutInMs} ms`), { name: "TimeoutError" }));
|
||
|
});
|
||
|
};
|