Repository navigation
Record request URL and HTTP status on failed downloads - #77
Merged
Merged
Conversation
A cross-origin response without CORS headers (e.g. a 429 from the proxy) makes fetch reject with a bare TypeError and hides the HTTP status from JS. Capture the resolved request URL and any exposed status in FetchError, and when the status is hidden and a proxy was used, probe reachability to tell 'reachable but blocked' apart from 'unreachable', plus an actionable hint.
✅ Deploy Preview for savrlist ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
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.
Why
While testing the app log (#70), a failed save only recorded:
That's not enough to act on. The underlying reason is a browser security boundary: when a cross-origin response fails the CORS check (no
Access-Control-Allow-Origin), the browser filters the response before JS sees it.fetchrejects with a bareTypeError, and there is noresponseobject — sostatus, headers, and body are all unavailable.XMLHttpRequest,no-corsfetches, andPerformanceResourceTiming.responseStatusall report0for such responses. The status is only readable when the response carries CORS headers.What
Generic failure context on downloads — no CORS-specific logic:
fetchWithTimeoutthrows aFetchErrorcarrying the resolvedrequestUrl(proxy included) and the HTTPstatuswhen the browser exposed one (src/utils/article/tools.ts).ingestUrllogsrequestUrlandstatuson failure; image-download failures carry the same.A failed save now logs:
{ "url": "https://github.com/...", "error": "Network error: NetworkError when attempting to fetch resource.", "requestUrl": "https://lively-cors-proxy-....workers.dev/?url=..." }and, when the proxy returns an error with CORS headers:
{ "url": "https://github.com/...", "error": "HTTP 429 Too Many Requests", "requestUrl": "https://lively-cors-proxy-....workers.dev/?url=...", "status": 429 }Testing
npx tsc --noEmit— cleannpx jest— 307 passednpm run lint— no new warningsBase of this PR is
main; the app-log feature it builds on (#70) is already merged. CHANGELOG updated.