Skip to content

feat(route): name why a Workoho route failed and bound its requests [25m] - #81

Merged
Gl4dr3x merged 3 commits into
masterfrom
feat/route-error-reason-and-utf8
Dec 1, 2026
Merged

Gl4dr3x merged 3 commits into
masterfrom
feat/route-error-reason-and-utf8

Conversation

@Gl4dr3x

@Gl4dr3x Gl4dr3x commented Dec 1, 2026 •

Copy link
Copy Markdown
Collaborator

Gap: A Workoho route that fails answers 503 with an HTML or JSON error page, so a reader such as Update Radar's ingest can only record "status 503", and a source that hangs shows up as the reader's own timeout because RSSHub's requests have no time limit. The EasyLife 365 changelog route takes over 30 seconds on every uncached request.

Change:

  • Reason header. A failing route answers with its error status and the response header RSSHub-Error-Reason. The value is one of four, fixed in lib/errors/types/route-failure.ts:
    • upstream-timeout: the route's source did not answer in time.
    • upstream-status: the source answered with an error status. RSSHub-Error-Upstream-Status carries that status (three digits).
    • upstream-unreachable: the source could not be reached (DNS, connection refused, reset).
    • parse-error: the source answered, but not with what the route reads (no item found, no JSON, no feed), so its page has probably changed.
  • The error handler (lib/errors/index.tsx, six lines) asks classifyFailure (lib/utils/route-failure.ts) for the reason. It names a failed request of any route, upstream's included, and a RouteFailureError a route raises itself; any other error, a bug in a route among them, gets no header and answers as before.
  • Bounded requests. The seven Workoho routes read their source through fetchUpstream: each attempt has 6 seconds for headers and body and carries its own abort signal, so a source that stalls its body is cut off and its connection closed. One retry after 500 ms, on a timeout, an unreachable source or a status that may pass (408, 425, 429, 500, 502, 503, 504); about 12.5 seconds at worst. The document is read as text and parsed after, so an error status with an HTML body is named as the status, not taken for bad JSON. Update Radar waits 15 seconds, so it now gets the reason instead of timing out itself. The seven are /easylife365/changelogs, /flexopus/changelog, /microsoft/message-center, /microsoftlearn/entra/whats-new, /microsoftlearn/intune/blog, /microsoftlearn/intune/in-development and /microsoftlearn/intune/whats-new. Each fails with parse-error when it finds no item, in place of RSSHub's generic "this route is empty".
  • No caching of a failure. A 503 kept the feed's Cache-Control: public, max-age from the header middleware. The error handler now answers no-store for every 503 but RSSHub's "request in progress", which keeps its own short max-age.
  • EasyLife 365 changelog. The route collected every /changelogs/ link of the overview, 135 today with the site's three feed files among them, and fetched each page on every request: 32 seconds measured here. It now reads the site's own JSON feed (/changelogs/feed.json): one request, the 20 newest entries, about 1 second. Links and titles are unchanged, so identifiers stay. The description is now the entry's HTML where it was flattened text, the date comes from the feed, and the entry's tags become categories.
  • UTF-8. RSSHub already declares charset=utf-8 for RSS, Atom and JSON Feed and for its error pages; no route changed for this. The tests now pin it for each of the seven routes in all three formats and decode the body strictly as UTF-8, so an upstream sync that breaks it fails here.

Intune "in development": not reproduced. Against the live page the route answers in 0.3 to 0.7 seconds here, before and after this change, with 16 items. What makes it time out on the instance needs the instance's logs. With this change a hanging request is aborted after 6 seconds and the answer names the reason, which will say what it is.

Proxy: the retry is fetchUpstream's own, so it goes out without the x-prefer-proxy header that RSSHub's built-in retry sets. No tracked deployment file (docker-compose.custom.yml, the workflows) sets a PROXY_* variable, so nothing is routed through a proxy today and the header would change nothing. What the hosting sets outside the repository is not visible from here; a proxy with the on_retry strategy would need the header on the retry.

To know before merging: a merge to master that touches lib/** starts the Docker build and the Coolify deploy. Update Radar will read the EasyLife entries as changed once, because their body changes from text to HTML.

Verified: vitest run lib/utils/route-failure.test.ts lib/errors/index.test.ts, 44 tests green on Windows with Node 24; the sources are mocked. All seven routes read once against their live sources through the application in dev mode, each 200 in about a second. The commit hook's oxlint, eslint and oxfmt pass on the changed files. Reviewed by two agents that did not write it; their three findings are fixed in the second commit. The third commit answers a second review (abort at the timeout with a test against a real listener that stalls its body, no-store, a connect timeout inside an AggregateError) and was not read again before the push. Rebased onto master after the Message Center guid change; that change is kept as merged, and the 44 tests pass on the rebased branch. Not run: the full suite, and nothing against the deployed instance. On GitHub the "Vitest on Node" jobs fail because Playwright does not support Chromium on ubuntu26.04; the PR before this one failed the same way, so that is not this change. lib/middleware/header.test.ts fails here in two tests on master as well (a 10 second timeout on the first request).

Tracked in workoho/updateradar#711.

An AI agent wrote this text in my name, on my instructions.

@Gl4dr3x Gl4dr3x self-assigned this Dec 1, 2026
@github-actions

github-actions Bot commented Dec 1, 2026

Copy link
Copy Markdown

Auto Route Test failed, please check your PR body format and reopen pull request. Check logs for more details.
自动路由测试失败,请确认 PR 正文部分符合格式规范并重新开启,详情请检查 日志。

@github-actions

github-actions Bot commented Dec 1, 2026

Copy link
Copy Markdown

Auto Route Test failed, please check your PR body format and reopen pull request. Check logs for more details.
自动路由测试失败,请确认 PR 正文部分符合格式规范并重新开启,详情请检查 日志。

const connect = Object.assign(new AggregateError([Object.assign(new Error('v6'), { code: 'ETIMEDOUT' }), Object.assign(new Error('v4'), { code: 'ECONNREFUSED' })], 'connect failed'), { code: 'ETIMEDOUT' });
const inner = new AggregateError([Object.assign(new Error('v6'), { code: 'ENETUNREACH' }), Object.assign(new Error('v4'), { code: 'UND_ERR_CONNECT_TIMEOUT' })], 'connect failed');
const refused = new AggregateError([Object.assign(new Error('v4'), { code: 'ECONNREFUSED' })], 'connect failed');
const fetchError = (cause: unknown) => Object.assign(new Error('fetch failed', { cause: new TypeError('fetch failed', { cause }) }), { name: 'FetchError' });
Gl4dr3x and others added 3 commits December 1, 2026 14:26
A route that fails now answers with the response header
RSSHub-Error-Reason next to its error status: upstream-timeout,
upstream-status, upstream-unreachable or parse-error. With
upstream-status, RSSHub-Error-Upstream-Status carries the status the
source answered with. The error handler classifies every route's error;
anything it cannot name gets no header.

The seven routes Workoho maintains read their source through
fetchUpstream: six seconds a request, one retry, so a reader that waits
15 seconds gets the reason instead of its own timeout. A source that
answers with something the route cannot read, or with no item, is a
parse error.

The EasyLife 365 changelog route read every changelog page on each
request, 135 of them, and took over 30 seconds. It reads the site's own
JSON feed now: one request, the 20 newest entries with their full HTML.

Tests pin that each of the seven routes declares charset=utf-8 and
delivers UTF-8 as RSS, Atom and JSON Feed.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
A JSON source that answered an error status with an HTML page was
reported as a parse error and not retried, because the body was parsed
before the status was checked. The document is read as text now and
parsed after. ofetch's timeout ends with the headers, so a deadline of
13 seconds covers the body too. A TypeError or SyntaxError from any
route no longer counts as a parse error: only an error a route raises
itself does.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
The 13 second deadline answered the reader but left the request
running when a source stalled its body. Each attempt now carries its
own signal with six seconds for headers and body, and the retry is
fetchUpstream's own: once, on a timeout, an unreachable source or a
status that may pass (408, 425, 429, 500, 502, 503, 504).

A failing route's 503 kept the feed's public max-age from the header
middleware; it answers no-store now. A connect that timed out on one of
several addresses arrives as an AggregateError and is named a timeout,
not unreachable. The upstream status header is set in an if.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@Gl4dr3x
Gl4dr3x force-pushed the feat/route-error-reason-and-utf8 branch from 38128e9 to b5ba024 Compare December 1, 2026 13:28
@Gl4dr3x
Gl4dr3x merged commit 4421f77 into master Dec 1, 2026
43 of 57 checks passed
@github-actions

github-actions Bot commented Dec 1, 2026

Copy link
Copy Markdown

Auto Route Test failed, please check your PR body format and reopen pull request. Check logs for more details.
自动路由测试失败,请确认 PR 正文部分符合格式规范并重新开启,详情请检查 日志。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants