Repository navigation
fix(preview): add failure reasons, retries, and cache TTL split - #19
Merged
Merged
Conversation
- PreviewUnavailableError now carries a structured reason and optional upstream status: blocked, rate_limited, upstream_error, timeout, unsupported_content_type, too_large, empty_body, redirect, invalid_url - Retry transient upstream 429/5xx responses once with jitter; map timeouts and 401/403/429/5xx separately - handlePreview logs preview_unavailable/preview_empty and returns the reason to the client, which shows specific blocked/temporary/format/size messages - Split preview and /api/items cache responses: the Cache API keeps the public 30-minute / 6-hour edge copy, while clients always receive private, no-store so the CDN Browser Cache TTL cannot extend them - Fall back to <html> for truncated documents so capped pages still extract readable prefixes; label truncation with too_large when nothing is readable - Bump app.js to v109 and the shell cache to v143 - Add retry/reason/timeout/too_large tests and update the docs Verified locally: Reuters -> 502 reason=blocked upstream_status=401 and the client shows the blocked-source message; arXiv PDF -> reason=unsupported_content_type with the format message; preview and items both return private, no-store on miss and Cache API hit; 92 tests, typecheck, audit, and dry-run pass. Co-Authored-By: Claude Code <noreply@anthropic.com>
|
🔎 Cloudflare preview: https://055d62a1-feedreader.phatpham9.workers.dev Uploaded from |
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.
Summary
Step 1 of the preview-reliability plan, plus the preview cache-TTL fix. The cron/refresh design is unchanged.
Structured preview failures
PreviewUnavailableErrornow carries areasonand optionalupstreamStatus:blocked,rate_limited,upstream_error,timeout,unsupported_content_type,too_large,empty_body,redirect,invalid_url.blocked, 429 torate_limited, and 5xx toupstream_error.handlePreviewlogspreview_unavailable/preview_emptyevents with the URL, reason, and upstream status, and returns the reason to the client.<html>as the content root, so a capped page can still extract a readable prefix. If truncation leaves no readable blocks, it is reported astoo_large.Cache TTL split for preview and items
/api/previewand/api/itemsnow use the same split as the home page:public, max-age=1800/21600),private, no-store.cf-cache-status: HIT,max-age=14400).expirationTtlkeeps the internal 30-minute / 6-hour Cache API lifetimes.Cache-Control.Versions
app.js→ v109reader-shell→ v143Verification
vitest run --exclude '.claude/**'; a local stale worktree under.claude/otherwise doubles discovery)npm audit(0),wrangler deploy --dry-run502reason=blocked,upstream_status=401, logpreview_unavailable; panel shows “This source blocks reader previews.”502reason=unsupported_content_type; panel shows “This article format can't be previewed.”private, no-storeon both a miss and a Cache API hit.too_large.Post-deploy check
After deploy,
/api/previewresponses should carrycache-control: private, no-store, and a blocked source should returnreason: "blocked"plusupstream_statusin the 502 body. Worker Logs should showpreview_unavailableevents.🤖 Generated with Claude Code