Skip to content

fix: Outlet's SPA fallback honours Route.static's load#49

Merged
jonlaing merged 1 commit into
mainfrom
fix/outlet-static-route-fallback
Jul 24, 2026
Merged

fix: Outlet's SPA fallback honours Route.static's load#49
jonlaing merged 1 commit into
mainfrom
fix/outlet-static-route-fallback

Conversation

@jonlaing

Copy link
Copy Markdown
Owner

Summary

`Outlet`'s fallback branch for "no `RouteDataProvider` in context" only checked `route._loader` and `route._handlers`. `Route.static` sets neither — its loader lives inside `_staticConfig.load` — so `hasHooks` was `false` for any static route, the branch was skipped, and `routeData` stayed at its initialized default:

```ts
let routeData: RouteDataService = {
data: undefined, // <-- STAYS undefined
loaderPath,
actions: {},
};
```

Then `route.render(routeData.data)` → user's render receives `undefined` → crashes on anything reading `data.title` / `data.foo` / etc.

Fix

Extend the fallback to run `_staticConfig?.load` when present:

```ts
const hasLoader =
route._loader != null || route._staticConfig?.load != null;
const hasHooks =
hasLoader || (route._handlers && route._handlers.length > 0);

if (hasHooks) {
const data = route._loader
? yield* route._loader({...})
: route._staticConfig?.load
? yield* route._staticConfig.load({ params: currentMatch.params })
: undefined;
routeData = { data, loaderPath, actions };
}
```

When this fires

  • Pure SPA mode (no `@effex/platform` layer at all): the primary case — no provider, so fallback runs.
  • Provider dropped in some subtree: if a nested `Outlet` or component tree bypasses the outer `RouteDataProvider`, this now degrades gracefully instead of blowing up.

Test plan

  • Full suite: 747 pass / 2 skipped
  • `npx tsc --noEmit` clean

🤖 Generated with Claude Code

Fallback branch only checked route._loader and route._handlers. Route.static sets neither — its loader lives inside _staticConfig.load. So hasHooks was false, the fallback block was skipped, and routeData stayed at its default with data: undefined. route.render(undefined) then crashed on any static-route render that touched its data arg.

Fallback now also runs _staticConfig?.load when present. Fixes Route.static in pure-SPA mode; also stops 'provider dropped through unexpectedly' cases from presenting as opaque 'Cannot read properties of undefined' errors from user code.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 24, 2026

Copy link
Copy Markdown

Deploying effex-api with  Cloudflare Pages  Cloudflare Pages

Latest commit: 932821b
Status: ✅  Deploy successful!
Preview URL: https://03e64dac.effex-api.pages.dev
Branch Preview URL: https://fix-outlet-static-route-fall.effex-api.pages.dev

View logs

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying effex with  Cloudflare Pages  Cloudflare Pages

Latest commit: 932821b
Status: ✅  Deploy successful!
Preview URL: https://b6aef497.effex.pages.dev
Branch Preview URL: https://fix-outlet-static-route-fall.effex.pages.dev

View logs

@jonlaing
jonlaing merged commit 379be56 into main Jul 24, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant