Skip to content

Loading, Errors and Retry

A server request takes time and can fail. Show a loading state, explain failures, and let users retry. A failed request should not be presented as a successful empty report.

Interactive example

Recover from a connection failure

This simulated backend can fail a request without clearing your last successful table.

Try it: Simulate connection failure, then choose Retry.

The example loads when visible.

What to notice: The old report stays visible during failure; retry loads sales by product.

This example uses a simulated backend. Trigger a failure, inspect the message, then retry. It demonstrates the client request lifecycle, not a deployed service or a database implementation.

The HTTP store or adapter receives the request’s cancellation signal. Pass it to your transport so a replaced report or closed view can cancel unnecessary work.

import type { PivotLoadRequest, PivotLoadResponse } from '@revolist/pivot';
async function load(request: PivotLoadRequest, signal?: AbortSignal): Promise<PivotLoadResponse> {
const response = await fetch('/api/pivot/load', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(request),
signal,
});
if (!response.ok) throw new Error('Could not load the sales report.');
return response.json();
}

This is a transport outline; a production endpoint must return the validated Pivot response, enforce access, and perform the requested calculations.

SituationExplain and offer
Network or temporary service failureRetry the current report
Expired session or denied accessSign in or request access; do not silently fall back to local data
Unsupported measure or queryChoose a supported field/operation
Report or export exceeds a limitReduce the scope or use an approved backend workflow
A newer report replaces the requestDiscard the stale result

Read retries and freshness are configured through caching and refresh. Explicit application actions remain separate from write retries. Respect the last accepted result, and tell users when it is being retained while the requested replacement has failed.

Request and response contracts, cache freshness, limits and recovery, and chart loading/error handling.