Repository navigation
feat(route): name why a Workoho route failed and bound its requests [25m] - #81
Merged
Merged
Conversation
| 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' }); |
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
force-pushed
the
feat/route-error-reason-and-utf8
branch
from
December 1, 2026 13:28
38128e9 to
b5ba024
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
RSSHub-Error-Reason. The value is one of four, fixed inlib/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-Statuscarries 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.lib/errors/index.tsx, six lines) asksclassifyFailure(lib/utils/route-failure.ts) for the reason. It names a failed request of any route, upstream's included, and aRouteFailureErrora route raises itself; any other error, a bug in a route among them, gets no header and answers as before.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-developmentand/microsoftlearn/intune/whats-new. Each fails withparse-errorwhen it finds no item, in place of RSSHub's generic "this route is empty".Cache-Control: public, max-agefrom the header middleware. The error handler now answersno-storefor every 503 but RSSHub's "request in progress", which keeps its own short max-age./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.charset=utf-8for 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 thex-prefer-proxyheader that RSSHub's built-in retry sets. No tracked deployment file (docker-compose.custom.yml, the workflows) sets aPROXY_*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 theon_retrystrategy would need the header on the retry.To know before merging: a merge to
masterthat toucheslib/**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'soxlint,eslintandoxfmtpass 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 anAggregateError) and was not read again before the push. Rebased ontomasterafter 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.tsfails here in two tests onmasteras 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.