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:
@@ -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) {
|
||||
|
||||
@@ -5,7 +5,7 @@ export const post_blob_percent_completed = temp_post_blob_percent_completed;
|
||||
export const temp_post_object_percent_completed = 0;
|
||||
export const post_object_percent_completed = temp_post_object_percent_completed;
|
||||
|
||||
// Updated 2026-01-08
|
||||
// Updated 2026-01-26 (Abort Silence)
|
||||
export const post_object = async function post_object({
|
||||
api_cfg = null,
|
||||
endpoint = '',
|
||||
@@ -169,13 +169,29 @@ export const post_object = async function post_object({
|
||||
const response = await fetch_method(url.toString(), fetchOptions).catch(function (
|
||||
error: any
|
||||
) {
|
||||
// SILENCE NOISE: Aborted requests shouldn't spam logs at log_lvl 0
|
||||
if (error.name === 'AbortError' || error.message?.includes('aborted') || error.name === 'TypeError') {
|
||||
if (log_lvl > 1) {
|
||||
console.log('API POST: Request was aborted or terminated by browser. Expected during navigation.', error);
|
||||
}
|
||||
return error;
|
||||
}
|
||||
|
||||
console.log(
|
||||
'API POST Object *fetch* request was aborted or failed in an unexpected way.',
|
||||
'API POST Object *fetch* request failed in an unexpected way.',
|
||||
error
|
||||
);
|
||||
return error;
|
||||
});
|
||||
clearTimeout(timeoutId);
|
||||
|
||||
// Check if we should stop due to abort or network failure
|
||||
if (response instanceof Error || (response && (response.name === 'TypeError' || response.name === 'AbortError'))) {
|
||||
if (response.name === 'AbortError') return false;
|
||||
if (log_lvl > 1) console.log('API POST Object: Detected NetworkError or TypeError. Failing fast.');
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!response) {
|
||||
throw new Error(
|
||||
`HTTP fetch request was aborted or failed in an unexpected way! URL = ${url.toString()}`
|
||||
|
||||
Reference in New Issue
Block a user