From d9c2cae649cc17ffdbfd61170142f9bf2fb0a294 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 20 Oct 2025 15:05:53 +0000 Subject: [PATCH 1/3] Initial plan From c00b11a2e035420d61a3f7099a0911465307c4bd Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 20 Oct 2025 15:08:18 +0000 Subject: [PATCH 2/3] Fix test to use ES6 import for locations.js Co-authored-by: richorama <353138+richorama@users.noreply.github.com> --- test/cb-endpoints-test.mjs | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/test/cb-endpoints-test.mjs b/test/cb-endpoints-test.mjs index 891e7f3..6168d52 100644 --- a/test/cb-endpoints-test.mjs +++ b/test/cb-endpoints-test.mjs @@ -12,28 +12,15 @@ * npm run test:endpoints */ -import { readFileSync } from 'fs'; import { fileURLToPath } from 'url'; -import { dirname, join } from 'path'; +import { dirname } from 'path'; // Get __dirname equivalent for ES modules const __filename = fileURLToPath(import.meta.url); const __dirname = dirname(__filename); -// Read and parse locations.js as text since it's CommonJS -const locationsPath = join(__dirname, '../lib/locations.js'); -const locationsContent = readFileSync(locationsPath, 'utf8'); - -// Use eval to execute the module.exports function in a safe context -// Extract just the function part -const funcMatch = locationsContent.match(/module\.exports = (\(\) => \[[\s\S]*?\]);/); -if (!funcMatch) { - throw new Error('Could not parse locations.js'); -} - -// Evaluate the function and call it to get the array -const getLocationsFunc = eval(funcMatch[1]); -const getLocations = getLocationsFunc; +// Import locations.js as an ES6 module +import getLocations from '../lib/locations.js'; // Test configuration const TEST_TIMEOUT = 10000; // 10 seconds From 808a06c94f28cb4cf80f7fac131815b354e3d700 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 20 Oct 2025 15:10:49 +0000 Subject: [PATCH 3/3] Fix timeoutId scoping issue in test Co-authored-by: richorama <353138+richorama@users.noreply.github.com> --- test/cb-endpoints-test.mjs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/cb-endpoints-test.mjs b/test/cb-endpoints-test.mjs index 6168d52..2d64e22 100644 --- a/test/cb-endpoints-test.mjs +++ b/test/cb-endpoints-test.mjs @@ -69,10 +69,11 @@ async function testEndpoint(location) { }; const startTime = Date.now(); + let timeoutId; try { const controller = new AbortController(); - const timeoutId = setTimeout(() => controller.abort(), TEST_TIMEOUT); + timeoutId = setTimeout(() => controller.abort(), TEST_TIMEOUT); const response = await fetch(url, { method: 'GET', @@ -87,7 +88,7 @@ async function testEndpoint(location) { result.success = true; // Any response (including 404, 500, etc.) is considered successful for latency testing } catch (error) { - clearTimeout(timeoutId); + if (timeoutId) clearTimeout(timeoutId); if (error.name === 'AbortError') { result.responseTime = Date.now() - startTime;