Frame the port-drawn gizmo in the CCTV QA drag fixture and share the catalog-pair reader

The drag-fixture framing looked the gizmo up in viewer.entities, which main no
longer populates, so it did nothing and five drag checks stayed inconclusive.
It now reads the arrow from the layer's drawn state and records the framed
shaft length as a check.

Tarktee and Lithuania read their two catalogs through one helper,
readCatalogsTogether, so both get the shared deadline, sibling abort and the
release of a response that arrives after the other feed failed.

An Ontario error response has its body released, and tests pin the refused
redirect and system-code log labels.
This commit is contained in:
Said Turksever committed 2026-11-19 18:06:58 +00:00
1 parent bdd92663d6
commit 75f1a3c181
9 files changed
+160 -92

No files matched your search

+13 -40
View File
@@ -172,6 +172,7 @@ import {
pinnedCameraUrl,
} from './normalize.js';
import { directionToHeading } from '../../../src/data/directionText.js';
import { readCatalogsTogether } from './catalogPair.js';
import {
readResponseBytesCapped,
readResponseJsonCapped,
@@ -621,6 +622,7 @@ export async function loadOntarioSourcesFromOpenData(
console.warn(
`[CCTV] Ontario 511 camera download failed: ${resp.status}${keyHint}`,
);
await resp.body?.cancel().catch(() => {});
return [];
}
const rows = await resp.json();
@@ -1296,47 +1298,18 @@ export function parseTarkteeDatexImages(xml) {
* @returns {Promise<Array<object>>} Normalized camera source objects.
*/
export async function loadTarkteeSourcesFromDatex() {
// One deadline for both feeds. Whichever read fails first aborts the other,
// so a stalled sibling is not waited on until the deadline.
const sibling = new AbortController();
const signal = AbortSignal.any([
sibling.signal,
AbortSignal.timeout(TARKTEE_FETCH_TIMEOUT_MS),
]);
const readXml = async (url, feed) => {
let response;
try {
response = await fetch(url, {
headers: { Accept: 'application/xml,text/xml,*/*' },
redirect: 'manual',
signal,
});
signal.throwIfAborted();
if (!response.ok) {
throw new Error(
response.status >= 300 && response.status < 400
? `${feed} catalog redirected; redirects are not followed`
: `${feed} download failed: ${response.status}`,
);
}
return await readResponseTextCapped(
response,
TARKTEE_MAX_CATALOG_BYTES,
signal,
);
} catch (error) {
// The join needs both feeds: stop the other one now, and release this
// body, including a response that arrived after the other failed.
sibling.abort();
await response?.body?.cancel().catch(() => {});
throw error;
}
};
try {
const [locXml, imgXml] = await Promise.all([
readXml(TARKTEE_LOCATIONS_URL, 'locations'),
readXml(TARKTEE_IMAGES_URL, 'images'),
]);
const [locXml, imgXml] = await readCatalogsTogether(
[
{ url: TARKTEE_LOCATIONS_URL, label: 'locations' },
{ url: TARKTEE_IMAGES_URL, label: 'images' },
],
{
accept: 'application/xml,text/xml,*/*',
maxBytes: TARKTEE_MAX_CATALOG_BYTES,
timeoutMs: TARKTEE_FETCH_TIMEOUT_MS,
},
);
const locations = parseTarkteeDatexLocations(locXml);
const images = parseTarkteeDatexImages(imgXml);
if (!locations.size || !images.size) {