tracker
All repositories: gitoria
2.3 KB
// Browser target: the host handles redirects and credential policy. Network reasons are limited by the host Fetch API.function reason(e, timedOut) {if (timedOut) return 'timed out';const code = e?.cause?.code || e?.code;if (code === 'ECONNREFUSED') return 'connection refused';if (code === 'ENOTFOUND' || code === 'EAI_AGAIN') return 'could not resolve host';if (code === 'ECONNRESET' || code === 'UND_ERR_SOCKET') return 'connection reset by peer';if (code === 'ETIMEDOUT' || code === 'UND_ERR_CONNECT_TIMEOUT') return 'timed out';return e?.cause?.message || e?.message || String(e);}async function exchange(url, options, tolerant) {const o = options || {};const method = o.method || 'GET';const controller = new AbortController();let timedOut = false;const timer = setTimeout(() => { timedOut = true; controller.abort(); }, o.timeoutMs ?? 30000);try {const headers = new Headers(o.headers || {});let body = o.body;if (o.json != null) {body = JSON.stringify(o.json);if (!headers.has('content-type')) headers.set('content-type', 'application/json');}// Generated modules use the runtime's Bytes wrapper; direct JS uses Uint8Array.if (body?._d instanceof Uint8Array) {const { hlIsBytes } = await import('../hl-runtime.js');if (hlIsBytes(body)) body = body._d;}if (body != null && typeof body !== 'string' && !(body instanceof Uint8Array)) {throw new Error('body must be a String or Bytes (use json for JSON)');}// Manual browser redirects hide status and Location (opaqueredirect).// A positive custom hop limit cannot be enforced through browser Fetch.const r = await globalThis.fetch(url, { method, headers, body, signal: controller.signal,redirect: o.maxRedirects === 0 ? 'manual' : 'follow' });const text = await r.text();return { status: r.status, ok: r.ok, url: r.url, headers: Object.fromEntries(r.headers),body: text, tag: o.tag || '', text() { return text; }, json() { return JSON.parse(text); } };} catch (e) {const error = `hl:fetch ${method} ${url}: ${reason(e, timedOut)}`;if (tolerant) return { ok: false, status: 0, error };throw new Error(error);} finally { clearTimeout(timer); }}export function fetch(url, options) { return exchange(url, options, false); }export function tryFetch(url, options) { return exchange(url, options, true); }
Branches
Latest commits
- 15917f03Record PR workflow rule (gitoria#50)mre
- 942ac995status: paused workers statemre
- 44b934e5log: respawn cleanupmre
- 03a80097Log: Anton GC A/Bmre
- c7cdef62Log: Apollo STOP, workers pausedmre
- d0c083fbLog: usage stopmre
- c6d464e5Log: Apollo GO backlog, AP56 and BS1 startedmre
- 1eb6f1a1Missions AP56, BS1mre
- 4871f8adLog: AP52 live on day52, browser gate greenmre
- d9bf2988Merge ap52: day52, tracker#58 server argument, #51 modal close rule, #56 keyed season rowsmre
- c4a60ef2Log: RT52 retest passed, AP52 startedmre
- 83760a55Browser gate: search results belong to the address form of the typed text (tracker#52 navigate replace)mre
- 6e951d91AP52: show-page rows are keyed records; closing a season is one upsert and removes (tracker#56, hybriel#331)mre
- 3bb4ccddAP52: modal close button refers to its nested rule with Style.buttonModalX (tracker#51, hybriel#333)mre
- ba16933fAP52: login callback and title route are static handlers taking the server as third argument (tracker#58, hybriel#332)mre
- 85153900AP52: re-vendor Hybriel set day52 (source 77cfca31, bin 0a8ed496)mre
- 7c051eddLog: hybriel#338 answermre
- d049b8b8Log: HM50 live, #52 donemre
- 6d05fa37Log: HM50 Part A mergedmre
- 1c7dab74HM50: the shell reads the framework's online state, netProbe removed (tracker#55)mre