mirror of
https://github.com/Pax1601/DCSOlympus.git
synced 2025-10-29 16:56:34 +00:00
Modified manager to new design
This commit is contained in:
@@ -11,4 +11,22 @@ function checkPort(port, callback) {
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = checkPort;
|
||||
async function fetchWithTimeout(resource, options = {}) {
|
||||
const { timeout = 8000 } = options;
|
||||
|
||||
const controller = new AbortController();
|
||||
const id = setTimeout(() => controller.abort(), timeout);
|
||||
|
||||
const response = await fetch(resource, {
|
||||
...options,
|
||||
signal: controller.signal
|
||||
});
|
||||
clearTimeout(id);
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
checkPort: checkPort,
|
||||
fetchWithTimeout: fetchWithTimeout
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user