fix: use TIMEOUTS constants instead of magic numbers in health and services routes
- health.js: replace magic number 5000 with TIMEOUTS.HTTP_DEFAULT (twice) - services.js: replace magic number 5000 with TIMEOUTS.HTTP_DEFAULT Both files already import TIMEOUTS from constants but weren't using it.
This commit is contained in:
@@ -45,7 +45,7 @@ module.exports = function({
|
|||||||
// Try HEAD first
|
// Try HEAD first
|
||||||
try {
|
try {
|
||||||
const controller = new AbortController();
|
const controller = new AbortController();
|
||||||
const timeout = setTimeout(() => controller.abort(), 5000);
|
const timeout = setTimeout(() => controller.abort(), TIMEOUTS.HTTP_DEFAULT);
|
||||||
const response = await fetchT(url, { method: 'HEAD', signal: controller.signal, redirect: 'follow' });
|
const response = await fetchT(url, { method: 'HEAD', signal: controller.signal, redirect: 'follow' });
|
||||||
clearTimeout(timeout);
|
clearTimeout(timeout);
|
||||||
return {
|
return {
|
||||||
@@ -59,7 +59,7 @@ module.exports = function({
|
|||||||
// Fallback to GET
|
// Fallback to GET
|
||||||
try {
|
try {
|
||||||
const controller = new AbortController();
|
const controller = new AbortController();
|
||||||
const timeout = setTimeout(() => controller.abort(), 5000);
|
const timeout = setTimeout(() => controller.abort(), TIMEOUTS.HTTP_DEFAULT);
|
||||||
const response = await fetchT(url, { method: 'GET', signal: controller.signal, redirect: 'follow' });
|
const response = await fetchT(url, { method: 'GET', signal: controller.signal, redirect: 'follow' });
|
||||||
clearTimeout(timeout);
|
clearTimeout(timeout);
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ module.exports = function({
|
|||||||
const headers = {};
|
const headers = {};
|
||||||
if (pylonConfig.key) headers['x-pylon-key'] = pylonConfig.key;
|
if (pylonConfig.key) headers['x-pylon-key'] = pylonConfig.key;
|
||||||
const controller = new AbortController();
|
const controller = new AbortController();
|
||||||
const timeout = setTimeout(() => controller.abort(), 5000);
|
const timeout = setTimeout(() => controller.abort(), TIMEOUTS.HTTP_DEFAULT);
|
||||||
const response = await fetchT(probeUrl, { method: 'GET', signal: controller.signal, headers });
|
const response = await fetchT(probeUrl, { method: 'GET', signal: controller.signal, headers });
|
||||||
clearTimeout(timeout);
|
clearTimeout(timeout);
|
||||||
if (!response.ok) return null;
|
if (!response.ok) return null;
|
||||||
|
|||||||
Reference in New Issue
Block a user