perf(hydration): optimize page loads and silence background fetch noise

- Implemented SWR pattern for Journal and Site Domain lookups.
- Refactored +layout.ts across modules to fire background refreshes instead of blocking.
- Updated +layout.svelte to render the layout shell immediately while hydrating.
- Silenced 'AbortError' and 'NetworkError' in api_get_object.ts and api_post_object.ts for log_lvl 0.
- Resolved duplicate export errors in ae_journals__journal.ts.
This commit is contained in:
Scott Idem
2026-01-26 17:06:22 -05:00
parent 715cc7cb65
commit c7a517a6e1
5 changed files with 150 additions and 392 deletions

View File

@@ -158,19 +158,29 @@ export const get_object = async function get_object({
const response = await fetch_method(url.toString(), fetchOptions).catch(function (
error: any
) {
// SILENCE NOISE: Aborted requests (common in SWR/Background loads) shouldn't spam logs
if (error.name === 'AbortError' || error.message?.includes('aborted') || error.name === 'TypeError') {
if (log_lvl > 1) {
console.log('API GET: Request was aborted or terminated by browser. This is expected during navigation.', error);
}
return error; // Return error to be handled below
}
console.log(
'API GET Object *fetch* request was aborted or failed in an unexpected way.',
'API GET Object *fetch* request failed in an unexpected way.',
error
);
// Return the error so we can check it
return error;
});
clearTimeout(timeoutId);
// If the catch returned an Error object instead of a Response
if (response instanceof Error || (response && response.name === 'TypeError')) {
console.log('API GET Object: Detected NetworkError or TypeError. Failing fast.');
return false; // Skip retries for dead servers/DNS
// Check if we should stop due to abort or network failure
if (response instanceof Error || (response && (response.name === 'TypeError' || response.name === 'AbortError'))) {
// If it was an explicit abort, definitely stop
if (response.name === 'AbortError') return false;
if (log_lvl > 1) console.log('API GET Object: Detected NetworkError or TypeError. Failing fast.');
return false;
}
if (!response) {