-
Notifications
You must be signed in to change notification settings - Fork 3
Fix docs chunk failures and error fallback #221
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
dcrawbuck
wants to merge
20
commits into
main
Choose a base branch
from
dcrawbuck/docs-indexing-debug
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
4c4a76a
Fix docs chunk failures and error fallback
dcrawbuck 33d1464
Retry staging build
dcrawbuck 7843a92
Simplify root error metadata handling
dcrawbuck bb5bdb2
Seed docs prerender pages directly
dcrawbuck 512f81e
Preload docs source on the server
dcrawbuck 2c6aa22
Move docs source loader server-only
dcrawbuck 317ccc7
Warm docs prerender before explicit pages
dcrawbuck 37ab06c
Use root crawl for docs prerender
dcrawbuck 2717da0
Bypass server function during docs SSR
dcrawbuck 8d7dc80
Keep docs source eager on SSR only
dcrawbuck 360b713
Keep root prerender boundary unchanged
dcrawbuck 47a0f6c
Scope docs error handling away from root
dcrawbuck e823122
Use direct docs server loader
dcrawbuck 6912237
Keep debug error route dev-only
dcrawbuck 8bf75c7
Remove temporary debug error route
dcrawbuck 5c0f37e
Disable docs prerender crawl
dcrawbuck 65d5827
Revert staging deploy experiments
dcrawbuck 2fcd036
Address docs review notes
dcrawbuck 7844e38
Restore docs structured data
dcrawbuck 0c9b6e6
Fix docs cache and chunk recovery
dcrawbuck File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| import assert from "node:assert/strict"; | ||
| import { describe, test } from "node:test"; | ||
| import { renderToString } from "react-dom/server"; | ||
| import { DocsError } from "./DocsError"; | ||
|
|
||
| describe("DocsError", () => { | ||
| test("renders an index-safe docs fallback instead of TanStack's default text", () => { | ||
| const html = renderToString(<DocsError error={new Error("boom")} reset={() => {}} />); | ||
|
|
||
| assert.match(html, /Error loading docs page/); | ||
| assert.doesNotMatch(html, /Something went wrong!/); | ||
| assert.doesNotMatch(html, /Show Error/); | ||
| assert.doesNotMatch(html, /boom/); | ||
| }); | ||
| }); |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| import type { ErrorComponentProps } from "@tanstack/react-router"; | ||
| import { AlertTriangle, Home, RefreshCw } from "lucide-react"; | ||
| import { useEffect } from "react"; | ||
| import { ERROR_PAGE_DESCRIPTION, ERROR_PAGE_TITLE, NOINDEX_ROBOTS_META } from "@/lib/metadata"; | ||
| import { buildDocsPath } from "@/lib/url-base"; | ||
|
|
||
| type DocsErrorProps = Pick<ErrorComponentProps, "reset"> & { | ||
| error?: unknown; | ||
| }; | ||
|
|
||
| function reloadPage(reset?: ErrorComponentProps["reset"]) { | ||
| reset?.(); | ||
| if (typeof window !== "undefined") { | ||
| window.location.reload(); | ||
| } | ||
| } | ||
|
|
||
| function upsertMeta(name: string, content: string) { | ||
| let element = document.querySelector(`meta[name="${name}"]`); | ||
| if (!(element instanceof HTMLMetaElement)) { | ||
| element = document.createElement("meta"); | ||
| element.name = name; | ||
| document.head.append(element); | ||
| } | ||
|
|
||
| element.content = content; | ||
| return element; | ||
| } | ||
|
|
||
| export function DocsError({ reset }: DocsErrorProps) { | ||
| useEffect(() => { | ||
| document.title = ERROR_PAGE_TITLE; | ||
| upsertMeta("description", ERROR_PAGE_DESCRIPTION); | ||
| const robotsMeta = upsertMeta("robots", NOINDEX_ROBOTS_META); | ||
|
|
||
| return () => { | ||
| if (robotsMeta.content === NOINDEX_ROBOTS_META) { | ||
| robotsMeta.remove(); | ||
| } | ||
| }; | ||
| }, []); | ||
|
|
||
| return ( | ||
| <main className="flex min-h-screen items-center justify-center bg-fd-background px-6 py-16 text-fd-foreground"> | ||
| <section className="w-full max-w-xl rounded-lg border border-fd-border bg-fd-card p-6 shadow-sm"> | ||
| <div className="flex items-start gap-4"> | ||
| <div className="flex size-10 shrink-0 items-center justify-center rounded-md bg-fd-muted text-fd-muted-foreground"> | ||
| <AlertTriangle className="size-5" aria-hidden="true" /> | ||
| </div> | ||
| <div className="min-w-0"> | ||
| <h1 className="text-xl font-semibold tracking-tight">Error loading docs page</h1> | ||
| <p className="mt-2 text-sm leading-6 text-fd-muted-foreground"> | ||
| An error prevented this page from loading. Try refreshing, or go back to the docs home | ||
| page. | ||
| </p> | ||
| </div> | ||
| </div> | ||
| <div className="mt-6 flex flex-col gap-3 sm:flex-row"> | ||
| <button | ||
| type="button" | ||
| onClick={() => reloadPage(reset)} | ||
| className="inline-flex h-10 items-center justify-center gap-2 rounded-lg border border-transparent bg-fd-primary px-4 text-sm font-medium text-fd-primary-foreground transition-colors hover:bg-fd-primary/80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-fd-ring" | ||
| > | ||
| <RefreshCw className="size-4" aria-hidden="true" /> | ||
| Refresh | ||
| </button> | ||
| <a | ||
| href={buildDocsPath()} | ||
| className="inline-flex h-10 items-center justify-center gap-2 rounded-lg border border-fd-border px-4 text-sm font-medium transition-colors hover:bg-fd-accent hover:text-fd-accent-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-fd-ring" | ||
| > | ||
| <Home className="size-4" aria-hidden="true" /> | ||
| Docs home | ||
| </a> | ||
| </div> | ||
| </section> | ||
| </main> | ||
| ); | ||
| } |
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When
pruneDeletedEntriesremoves existing entries here, a delete-only docs change (or any run where the only stale entries are for deleted files) can still leavenewChanges.length === 0, so the early return below exits without callingwriteChangelogIfChanged. SinceChangelogTimelineno longer validates URLs againstsource.getPages(), those stale deleted-page entries remain inchangelog-entries.jsonand can render broken changelog links until an unrelated new entry is generated.Useful? React with 👍 / 👎.