Repository navigation
feat(appkit): replace React Router's default error page with an AppKit error page - #749
Open
MarioCadenas wants to merge 9 commits into
Open
MarioCadenas wants to merge 9 commits into
MarioCadenas wants to merge 9 commits into
Conversation
hasReactRouter() resolved react-router with Node's resolution, which also searches NODE_PATH. pnpm's bin shims point NODE_PATH at the workspace's hidden hoisted packages, so a copy the app's Vite never resolves could switch design pages into router mode. Look for node_modules/react-router from the design page up instead, as Vite does. Co-authored-by: Isaac <no-reply@databricks.com> Signed-off-by: mario.cadenas <mario.cadenas@databricks.com>
A page to show instead of the router's built-in error page: it says that something went wrong (for a 404 route error response, that the page was not found) and offers a reload and the home page. The message and stack show only in development (import.meta.env.DEV). It takes the error as a prop, so it works with React Router's useRouteError() or TanStack Router's errorComponent; route error responses are recognised by shape. react-router 7.18.0 (the template's pin) is a devDependency for the tests, which render a real router: a route that throws, a 404, details hidden outside development, and a route's own errorElement winning. Co-authored-by: Isaac <no-reply@databricks.com> Signed-off-by: mario.cadenas <mario.cadenas@databricks.com>
…te and design pages A route that throws showed React Router's built-in page: "Hey developer" while developing, and the error's message and stack in a deployed app. The template's root layout route now has an errorElement: a page built from AppKit UI components that says something went wrong and offers Reload and Back to home, with the stack only in development; a 404 route error response renders the existing NotFoundPage. It is defined in App.tsx rather than importing ErrorPage, because the template pins the published @databricks/appkit-ui, which doesn't have ErrorPage yet. Design pages' router gets appkit-ui's ErrorPage as its root ErrorBoundary, for a page that fails to load or doesn't exist. Co-authored-by: Isaac <no-reply@databricks.com> Signed-off-by: mario.cadenas <mario.cadenas@databricks.com>
The root CatchBoundary renders appkit-ui's ErrorPage instead of the playground's own error card (which showed the message in production too), and a new /error-page route under Platform throws on render to show it. Co-authored-by: Isaac <no-reply@databricks.com> Signed-off-by: mario.cadenas <mario.cadenas@databricks.com>
Also regenerates docs/static/appkit-ui/styles.gen.css for the classes ErrorPage uses. Co-authored-by: Isaac <no-reply@databricks.com> Signed-off-by: mario.cadenas <mario.cadenas@databricks.com>
…ErrorPage A 404 route error response now offers Reload as well as Back to home, as the other errors do. The development details no longer throw for a value String() can't convert (Object.create(null)): the page renders "[object Object]" instead of crashing into an outer error boundary. Co-authored-by: Isaac <no-reply@databricks.com> Signed-off-by: mario.cadenas <mario.cadenas@databricks.com>
The template's RouteErrorPage rendered NotFoundPage for a 404 route error response, without Reload or development details, and built its details with String(error) before the development check, so a thrown Object.create(null) crashed it in production into the outer boundary, which shows stacks. It now shows "Page not found" with Reload, Back to home and development-only details, builds the details only in development without throwing, and links home with a plain anchor (a full page load, as ErrorPage does). Co-authored-by: Isaac <no-reply@databricks.com> Signed-off-by: mario.cadenas <mario.cadenas@databricks.com>
…ails In development, the template's error page showed only the status of a route error response; it now adds the response's text when it is a string (e.g. "No such order" from a loader's 404), as ErrorPage does. Co-authored-by: Isaac <no-reply@databricks.com> Signed-off-by: mario.cadenas <mario.cadenas@databricks.com>
It opens the route that throws and checks that AppKit's error page shows inside the playground layout, with Reload and Back to home, that React Router's text is absent, and that the dev server shows the thrown message. Co-authored-by: Isaac <no-reply@databricks.com> Signed-off-by: mario.cadenas <mario.cadenas@databricks.com>
Contributor
📦 Bundle size reportCompared against
|
| dist | raw | gzip |
|---|---|---|
| JS (runtime) | 1.4 MB (+275 B) | 501 KB (+120 B) |
| Type declarations | 482 KB | 174 KB |
| Source maps | 2.7 MB (+160 B) | 931 KB (+86 B) |
| Other | 11 KB | 3.7 KB |
| Total | 4.6 MB (+435 B) | 1.6 MB (+206 B) |
Per-entry composition (own code — deps external (as shipped))
| Entry | Initial (gz) | Lazy (gz) | Total (gz) | node_modules (min) | Own code (min) |
|---|---|---|---|---|---|
. |
118 KB | 2.4 KB | 121 KB | external | 378 KB |
./beta |
118 KB (+64 B) | 4.5 KB | 123 KB (+64 B) | external | 356 KB (+166 B) |
./testing |
47 KB | 38 KB | 85 KB | external | 246 KB |
./tsdown |
630 B | 0 B | 630 B | external | 1.0 KB |
./type-generator |
31 KB | 0 B | 31 KB | external | 89 KB |
Chunks:
| Entry | Chunk | Load | Size (gz) |
|---|---|---|---|
. |
index.js |
initial | 114 KB |
. |
utils.js |
initial | 4.6 KB |
. |
remote-tunnel-manager.js |
lazy | 2.4 KB |
./beta |
beta.js |
initial | 92 KB |
./beta |
stream-manager.js |
initial | 5.9 KB |
./beta |
define-schema.js |
initial | 5.8 KB |
./beta |
service-context.js |
initial | 4.3 KB |
./beta |
modular.js |
initial | 3.6 KB |
./beta |
databricks.js |
initial | 3.3 KB |
./beta |
wide-event-emitter.js |
initial | 2.8 KB |
./beta |
client.js |
initial | 645 B |
./beta |
index.js |
initial | 20 B |
./beta |
index.js |
lazy | 4.0 KB |
./beta |
supervisor-api.js |
lazy | 201 B |
./beta |
databricks.js |
lazy | 188 B |
./beta |
index.js |
lazy | 124 B |
./testing |
manifest.js |
initial | 33 KB |
./testing |
index.js |
initial | 10 KB |
./testing |
wide-event-emitter.js |
initial | 2.9 KB |
./testing |
index.js |
lazy | 34 KB |
./testing |
remote-tunnel-manager.js |
lazy | 2.4 KB |
./testing |
utils.js |
lazy | 1.8 KB |
./tsdown |
index.js |
initial | 630 B |
./type-generator |
index.js |
initial | 31 KB |
@databricks/appkit-ui
npm tarball (packed): 396 KB (+2.8 KB) — gzipped download (dist + bin; excludes release-only docs/NOTICE).
| dist | raw | gzip |
|---|---|---|
| JS (runtime) | 433 KB (+2.7 KB) | 147 KB (+1.2 KB) |
| Type declarations | 251 KB (+1.0 KB) | 93 KB (+568 B) |
| Source maps | 842 KB (+4.5 KB) | 283 KB (+2.0 KB) |
| CSS | 16 KB | 3.2 KB |
| Total | 1.5 MB (+8.3 KB) | 526 KB (+3.8 KB) |
Per-entry composition (consumer bundle — deps bundled, peerDeps external)
| Entry | Initial (gz) | Lazy (gz) | Total (gz) | node_modules (min) | Own code (min) |
|---|---|---|---|---|---|
./js |
5.3 KB | 49 KB | 55 KB | 208 KB | 14 KB |
./js/beta |
2.4 KB | 0 B | 2.4 KB | 0 B | 5.3 KB |
./react |
441 KB (+599 B) | 49 KB | 490 KB (+599 B) | 1.4 MB (+312 B) | 181 KB (+1.2 KB) |
./react/beta |
13 KB | 0 B | 13 KB | 25 KB | 13 KB |
Chunks:
| Entry | Chunk | Load | Size (gz) |
|---|---|---|---|
./js |
index.js |
initial | 5.2 KB |
./js |
chunk |
initial | 120 B |
./js |
apache-arrow |
lazy | 49 KB |
./js/beta |
beta.js |
initial | 2.4 KB |
./react |
index.js |
initial | 439 KB |
./react |
tslib |
initial | 2.1 KB |
./react |
apache-arrow |
lazy | 49 KB |
./react/beta |
beta.js |
initial | 13 KB |
Contributor
🤖 AppKit PR bot🔬 Run evalsStart an eval for this PR from the evals-monitor app: Go to Evals Monitor → 📦 Try this PR's app templateScaffolds a new app from this PR's SDK build. Run it in any folder (requires the GitHub CLI — gh run download 45654862123 -R databricks/appkit -n appkit-template-0.105.0-pr.f33f099-work-17-replace-react-router-s-default-749 -D appkit-pr-749 \
&& unzip -o "appkit-pr-749/appkit-template-0.105.0-pr.f33f099-work-17-replace-react-router-s-default-749.zip" -d "appkit-pr-749" \
&& databricks apps init --template "appkit-pr-749"The template pins |
This branch has not been deployed
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.
What
A route that throws in an AppKit app now shows an AppKit error page instead of React Router's built-in one. React Router's page says "Hey developer 👋" while developing, and in a production build it still shows "Unexpected Application Error!" with the error's message and stack, so deployed apps leaked stack traces.
ErrorPagein@databricks/appkit-ui/react(new,packages/appkit-ui/src/react/error-page.tsx):Empty,Buttonand lucide icons. It says "Something went wrong" and offers Reload and Back to home.import.meta.env.DEVis true. Building them never throws, even for a valueString()can't convert, such asObject.create(null).useRouteError(), or theerrorTanStack Router gives anerrorComponent. A route error response is recognised by its shape (numericstatus, stringstatusText).template/client/src/App.tsx):errorElement: <RouteErrorPage />.errorElementstill wins.designplugin): the/designrouter getsErrorPageas its rootErrorBoundary, for a page that fails to load or doesn't exist.CatchBoundaryrendersErrorPage, replacing the playground's own error card, which showed the message in production too./error-pageroute (under Platform) throws on render to show it.tests/error-page.spec.ts, checks it: the page shows inside the layout, with Reload and Back to home, React Router's text is absent, and the dev server shows the thrown message.docs/docs/api/appkit-ui/error-page.mdcovers what the page shows, how the template wires it, and how to replace it.Why
End users of AppKit apps should never see React Router's developer page, or a stack trace from a deployed app.
Notes for reviewers
ErrorPage. The template pins the published@databricks/appkit-ui, which doesn't export it yet. Importing it fails the template build (TS2305: Module '"@databricks/appkit-ui/react"' has no exported member 'ErrorPage') and with it CI's template deploy-shape jobs. Once a release withErrorPageis pinned,RouteErrorPagecan become<ErrorPage error={useRouteError()} />.react-router@7.18.0, the template's pin, MIT licensed, used by the appkit-ui tests only. They render a real router, which is the only way to show React Router's default text is gone.fix(appkit), design plugin:hasReactRouter()used Node's resolution, which also searchesNODE_PATH. pnpm's bin shims point that at the workspace's hidden hoisted packages. With react-router 7 now in the workspace, it "found" a router for an app without one. It now looks only fornode_modules/react-routerfrom the design page up, as Vite resolves it.How it was verified
pnpm install --frozen-lockfile && pnpm run check && pnpm run knip && pnpm build && pnpm run typecheck && pnpm vitest run --changed …passed, 6643 tests.error-page.test.tsx) use a real React Router and show:Object.create(null)renders, in development and production;DEVis false;errorElementwins.error-page.spec.ts.tools/smoke-test-template.ts --runpassed (install, build, start), and so did the--all-pluginsrun (typecheck and lint).Object.create(null), a route with its ownerrorElement), in development and production builds, and the playground's/error-page. Details show in development and are hidden in production.This pull request and its description were written by Isaac.