## Demo: defer-invalidation ### DeferInvalidation.svelte ```svelte
Loading
Loading
Loading

Error modes

A reload can fail in two different places, and they are not the same thing: the render can throw while the island is being built on the server, or the request for that HTML can fail. Only the second counts as a failed reload.

Loading
Loading
``` ### Controls.svelte ```svelte
Island 1
{one.count} reloads · {stamp(one)}
Islands 2 + 3
{pair.count} reloads · {stamp(pair)}
``` ### ServerClock.svelte ```svelte
{label} rendered {renderedAt}
``` ### LiveCounter.svelte ```svelte
{label} hydrated rendered {renderedAt}
``` ### ErrorModes.svelte ```svelte

Island 4 throws about half the time. Its own <svelte:boundary> catches it, so the island degrades to its failed snippet and the rest of the page is untouched. The fetch itself was fine, so lastReloadOk stays true.

Island 4: {rendered.count} reloads · {stamp(rendered)}

This one breaks the request instead of the render. Nothing comes back to swap in, so the island keeps the content it already had and lastReloadOk flips to false. Note the timestamp on island 5 does not change.

Island 5: {offline.count} reloads · {stamp(offline)}

``` ### FlakyPanel.svelte ```svelte {#snippet failed(error)}
{label} failed — {error.message}
{/snippet}
``` ### FlakyContent.svelte ```svelte
{label} rendered {renderedAt}
``` ### routes.ts ```ts import { Mochi } from 'mochi-framework'; import type { MochiRouteValue } from 'mochi-framework'; export const routes: Record = { '/demos/defer-invalidation': Mochi.page('./src/demos/defer-invalidation/DeferInvalidation.svelte'), }; ``` ### index.ts ```ts import { Mochi, logger } from 'mochi-framework'; import { routes } from './routes'; await Mochi.serve({ port: 3333, development: process.env.MODE === 'development', routes, }); logger.info('Server running at http://localhost:3333'); ```