diff --git a/.github/workflows/llms-full.yml b/.github/workflows/llms-full.yml index 66d82124c0..3b7ca7a3da 100644 --- a/.github/workflows/llms-full.yml +++ b/.github/workflows/llms-full.yml @@ -71,6 +71,7 @@ jobs: "cache-control": "no-cache", pragma: "no-cache", }, + signal: AbortSignal.timeout(30_000), }); if (response.status === 410) { console.log("::notice::Live Worker still returns 410 for /llms-full.txt; skipping corpus generation until the router is redeployed."); @@ -162,6 +163,7 @@ jobs: "cache-control": "no-cache", pragma: "no-cache", }, + signal: AbortSignal.timeout(30_000), }); if (!response.ok) throw new Error(`${path}: HTTP ${response.status}`); const contentType = response.headers.get("content-type") ?? ""; diff --git a/.github/workflows/r2-pages.yml b/.github/workflows/r2-pages.yml index 9db0e15e3f..fdd000ade9 100644 --- a/.github/workflows/r2-pages.yml +++ b/.github/workflows/r2-pages.yml @@ -267,10 +267,10 @@ jobs: set -euo pipefail verify_response="" if [ -n "${CLOUDFLARE_API_TOKEN:-}" ] && [ -n "${CLOUDFLARE_ACCOUNT_ID:-}" ]; then - verify_response="$(curl -fsS -H "Authorization: Bearer ${CLOUDFLARE_API_TOKEN}" "https://api.cloudflare.com/client/v4/accounts/${CLOUDFLARE_ACCOUNT_ID}/tokens/verify" || true)" + verify_response="$(curl --max-time 30 -fsS -H "Authorization: Bearer ${CLOUDFLARE_API_TOKEN}" "https://api.cloudflare.com/client/v4/accounts/${CLOUDFLARE_ACCOUNT_ID}/tokens/verify" || true)" fi if [ -z "${verify_response}" ] && [ -n "${CLOUDFLARE_API_TOKEN:-}" ]; then - verify_response="$(curl -fsS -H "Authorization: Bearer ${CLOUDFLARE_API_TOKEN}" "https://api.cloudflare.com/client/v4/user/tokens/verify" || true)" + verify_response="$(curl --max-time 30 -fsS -H "Authorization: Bearer ${CLOUDFLARE_API_TOKEN}" "https://api.cloudflare.com/client/v4/user/tokens/verify" || true)" fi if [ -n "${verify_response}" ]; then VERIFY_RESPONSE="${verify_response}" node - <<'NODE' @@ -300,6 +300,7 @@ jobs: "Content-Type": "application/json", }, method: "POST", + signal: AbortSignal.timeout(30_000), }); if (temporary.ok) { const data = await temporary.json(); diff --git a/CHANGELOG.md b/CHANGELOG.md index 3df34e5018..28fa151542 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## Unreleased +- Abort stalled publish probes and R2 credential calls after 30 seconds, and keep the community invitation inside narrow WebKit viewports. Thanks @SebTardif! (#318) + - Refresh Lucide, Playwright, Slugify, and pinned translation actions within the two-day dependency cooldown while preserving published anchors. Thanks @dependabot! - Keep search working across Pagefind upgrades by versioning its runtime and worker URLs and shortening legacy cache lifetimes. Thanks @0carespal! (#309) diff --git a/README.md b/README.md index 43bebb8ac2..2635967fe1 100644 --- a/README.md +++ b/README.md @@ -61,6 +61,8 @@ For official OpenClaw support, visit [community.openclaw.ai](https://community.o - Cloudflare deploys `workers/docs-router.ts`, which serves slashless page URLs, English markdown responses for `.md` paths or `Accept: text/markdown`, and `/api/search` through the `DOCS_BUCKET` R2 binding. - Cloudflare hosting details and limitations are documented in `CLOUDFLARE.md`. +Publish route probes, corpus smoke checks, Cloudflare token checks, and temporary R2 credential requests have a 30-second deadline so stalled connections reach the existing retry or fallback handling. + Signed R2 requests default to a 30-second per-request timeout. A stalled request enters the existing retry loop. Set `R2_UPLOAD_FETCH_TIMEOUT_MS` to an integer from 1 to 2147483647 milliseconds to raise that budget. The workflow job timeout diff --git a/scripts/docs-site/community-invite-visual.mjs b/scripts/docs-site/community-invite-visual.mjs index 953ec11118..0781a689a4 100644 --- a/scripts/docs-site/community-invite-visual.mjs +++ b/scripts/docs-site/community-invite-visual.mjs @@ -77,6 +77,7 @@ try { const button = link.getBoundingClientRect(); return button.left >= rect.left && button.right <= rect.right && button.top >= rect.top && button.bottom <= rect.bottom && link.scrollWidth <= link.clientWidth; }), + box: { left: rect.left, right: rect.right, top: rect.top, bottom: rect.bottom, innerWidth, innerHeight }, inViewport: rect.left >= -1 && rect.right <= innerWidth + 1 && rect.top >= -1 && rect.bottom <= innerHeight + 1, noOverflow: document.documentElement.scrollWidth <= innerWidth + 1, sidebarClear: innerWidth > 820 || document.querySelector(".sidebar").getBoundingClientRect().bottom <= rect.top + 1, @@ -91,7 +92,10 @@ try { }); assert.deepEqual(state.links, expectedLinks, label); assert.deepEqual(state.accessibleNames, ["Join the OpenClaw community on Reddit", "Join the OpenClaw community on Discord", "Follow OpenClaw on X"], label); - for (const property of ["safeLinks", "allLinksFit", "inViewport", "noOverflow", "sidebarClear", "fades", "marksAligned", "marksWhite", "targets"]) assert.equal(state[property], true, `${label}: ${property}`); + for (const property of ["safeLinks", "allLinksFit", "inViewport", "noOverflow", "sidebarClear", "fades", "marksAligned", "marksWhite", "targets"]) { + const detail = property === "inViewport" ? ` ${JSON.stringify(state.box)}` : ""; + assert.equal(state[property], true, `${label}: ${property}${detail}`); + } assert.deepEqual(state.art, [`/assets/community-invite-${theme}.webp`], label); assert.equal(state.marksBottom, "19px", label); assert.ok(mobile ? state.radius === 0 : state.radius > 0, `${label}: corner geometry`); diff --git a/scripts/docs-site/docs-layout.css b/scripts/docs-site/docs-layout.css index f087d3ef10..19ca260f9c 100644 --- a/scripts/docs-site/docs-layout.css +++ b/scripts/docs-site/docs-layout.css @@ -560,6 +560,8 @@ .docs-layout .main { border: 0; } .docs-layout .article, .docs-layout.docs-home-layout .article { padding-inline: 24px; } .docs-layout :is(.sidebar,.community-invite) { width: min(380px,100vw); } + /* 100vw includes a classic scrollbar, so a fixed card can extend past the layout viewport. */ + .docs-layout .community-invite { box-sizing: border-box; width: min(380px, 100%); max-height: 100dvh; } .docs-layout .sidebar { --docs-sidebar-inset-end: 20px; top: 0; padding: 0 20px; max-height: 100dvh; height: 100dvh; } .docs-layout .sidebar-head { min-height: 60px; margin: 0; padding-block: 8px; justify-content: space-between; border-bottom: 1px solid var(--docs-border); } .docs-layout .sidebar-brand { min-height: 44px; gap: 8px; } diff --git a/scripts/docs-site/publish-fetch-timeouts.test.mjs b/scripts/docs-site/publish-fetch-timeouts.test.mjs new file mode 100644 index 0000000000..081910a624 --- /dev/null +++ b/scripts/docs-site/publish-fetch-timeouts.test.mjs @@ -0,0 +1,105 @@ +import assert from "node:assert/strict"; +import fs from "node:fs"; +import http from "node:http"; +import vm from "node:vm"; +import test from "node:test"; +import { fileURLToPath } from "node:url"; + +function loadWorkflow(name) { + return fs.readFileSync(fileURLToPath(new URL(`../../.github/workflows/${name}`, import.meta.url)), "utf8"); +} + +function extractFetchCalls(source) { + const calls = []; + const needle = "await fetch("; + let from = 0; + while (from < source.length) { + const start = source.indexOf(needle, from); + if (start === -1) break; + let i = start + needle.length; + let depth = 1; + let quote = null; + while (i < source.length && depth > 0) { + const ch = source[i]; + if (quote) { + if (ch === "\\") { + i += 2; + continue; + } + if (ch === quote) quote = null; + } else if (ch === '"' || ch === "'" || ch === "`") { + quote = ch; + } else if (ch === "(") { + depth += 1; + } else if (ch === ")") { + depth -= 1; + } + i += 1; + } + calls.push(source.slice(start, i)); + from = i; + } + return calls; +} + +test("llms-full inline fetches abort", () => { + const fetches = extractFetchCalls(loadWorkflow("llms-full.yml")); + assert.equal(fetches.length, 2); + for (const call of fetches) { + assert.match(call, /signal:\s*AbortSignal\.timeout\(\s*30_000\s*\)/); + } +}); + +test("r2-pages credential calls abort", () => { + const source = loadWorkflow("r2-pages.yml"); + const fetches = extractFetchCalls(source); + assert.equal(fetches.length, 1); + assert.match(fetches[0], /signal:\s*AbortSignal\.timeout\(\s*30_000\s*\)/); + const curls = source.split("\n").filter((line) => line.includes("curl ")); + assert.equal(curls.length, 2); + for (const line of curls) { + assert.match(line, /--max-time\s+30(?:\s|$)/); + } +}); + +// Execute the workflow calls against a server that accepts connections but never replies. +test("stalled workflow requests abort before retry and credential fallback handling", async () => { + const server = http.createServer(() => {}); + await new Promise((resolve) => server.listen(0, "127.0.0.1", resolve)); + const url = `http://127.0.0.1:${server.address().port}`; + try { + for (const workflow of ["llms-full.yml", "r2-pages.yml"]) { + for (const call of extractFetchCalls(loadWorkflow(workflow))) { + const cleanup = new AbortController(); + const context = { + url, accountId: "synthetic-account", bucket: "synthetic-bucket", + accessKeyId: "synthetic-key", token: "synthetic-token", JSON, + AbortSignal: { timeout(ms) { + assert.equal(ms, 30_000); + return AbortSignal.timeout(30); + } }, + fetch: (_url, options) => fetch(url, { + ...options, + signal: AbortSignal.any([cleanup.signal, ...(options.signal ? [options.signal] : [])]), + }), + }; + let watchdog; + try { + const outcome = await Promise.race([ + vm.runInNewContext(`(async () => ${call})()`, context).then( + () => "resolved", (error) => error.name, + ), + new Promise((resolve) => { watchdog = setTimeout(() => resolve("stalled"), 1_000); }), + ]); + assert.equal(outcome, "TimeoutError", workflow); + } finally { + clearTimeout(watchdog); + cleanup.abort(); + } + } + } + } finally { + server.closeAllConnections(); + await new Promise((resolve) => server.close(resolve)); + } +}); diff --git a/scripts/docs-site/site-layout.css b/scripts/docs-site/site-layout.css index 36f690996c..d33a7e20fb 100644 --- a/scripts/docs-site/site-layout.css +++ b/scripts/docs-site/site-layout.css @@ -178,6 +178,7 @@ body:not(.docs-home) .doc .oc-card-group:not(.oc-card-cols-1):not(.oc-card-cols- } @media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } + .community-invite { transition: none; } } /* Shared network chrome and a search-led landing page, matching the community. */