APP-10Recommended
Show what loaded when one part fails
When a view combines several sources and one fails, show the parts that loaded and name the part that is missing.
How to do it
Load the sources independently and wait for all of them to settle, not for the first failure. Render each loaded part, and put a short notice with a retry button in place of the failed one. Never show totals that silently leave out a failed source. Hide the total or mark it as incomplete. It follows the website rule to keep working when a script or service fails.
Examples
TypeScript example
const [orders, refunds, payouts] = await Promise.allSettled([loadOrders(), loadRefunds(), loadPayouts()]);
const dashboard = {
orders: orders.status === 'fulfilled' ? orders.value : null,
refunds: refunds.status === 'fulfilled' ? refunds.value : null,
payouts: payouts.status === 'fulfilled' ? payouts.value : null,
};
const isTotalComplete = Object.values(dashboard).every(part => part !== null);
Python example
import asyncio
orders, refunds, payouts = await asyncio.gather(
load_orders(), load_refunds(), load_payouts(), return_exceptions=True
)
dashboard = {name: None if isinstance(part, Exception) else part
for name, part in {"orders": orders, "refunds": refunds, "payouts": payouts}.items()}
is_total_complete = all(part is not None for part in dashboard.values())
How to check
A test fails one of three sources. The other two render, the failed part shows its notice, and no total is shown as complete.
Sources
Related rules
- WEB-222 Keep working when a script or service fails in Website
For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/app-ui/data-views/partial-results">Agent Wranglers web app interface playbook</a>. In code you write, add a comment next to it with the same link.