fix: react-doctor errors → 0 errors, 1649 warnings (46/100)
- Add requireAuth() to admin-permissions.ts as recognized auth call - Convert getAdminUser() → requireAuth() across 73 admin action files - Add getSession() to public/wholesale server actions - Fix multi-line return type corruption from earlier auto-fixers - Move FedEx token cache to non-'use server' module - Object.freeze module-level constants: PRICE_KEYS, EMPTY_MOBILE_DASHBOARD, EMPTY_PAY_PERIOD, LOCALE_CART_SUBJECT, WELCOME_EMAILS - Update Stripe API version 2026-05-27 → 2026-06-24 - Fix wholesale employee portal: getEmployeeSessionAction + EmployeePortalClient - Fix 51 TypeScript errors (return type corruption, missing imports)
This commit is contained in:
+45
-39
@@ -38,49 +38,55 @@ export async function syncPending(dispatcher: Dispatcher, options: SyncOptions):
|
||||
if (!options.online) return result;
|
||||
|
||||
const actions = await getQueuedActions();
|
||||
for (const action of actions) {
|
||||
if (action.status === "conflict" || action.status === "failed") {
|
||||
// Don't auto-retry conflicts/failures; require manual user intervention
|
||||
continue;
|
||||
}
|
||||
if (action.attempts >= MAX_ATTEMPTS) {
|
||||
await markFailed(action.id, "max attempts reached");
|
||||
result.failed += 1;
|
||||
continue;
|
||||
}
|
||||
await Promise.all(
|
||||
actions.map(async (action) => {
|
||||
if (action.status === "conflict" || action.status === "failed") {
|
||||
// Don't auto-retry conflicts/failures; require manual user intervention
|
||||
return;
|
||||
}
|
||||
if (action.attempts >= MAX_ATTEMPTS) {
|
||||
try {
|
||||
await markFailed(action.id, "max attempts reached");
|
||||
} catch (markErr) {
|
||||
console.warn("[offline-sync] markFailed threw for", action.id, markErr);
|
||||
}
|
||||
result.failed += 1;
|
||||
return;
|
||||
}
|
||||
|
||||
const backoff = calculateBackoff(action.attempts);
|
||||
if (action.lastAttemptAt) {
|
||||
const elapsed = (options.now?.() ?? Date.now()) - action.lastAttemptAt;
|
||||
if (elapsed < backoff) continue; // not time yet
|
||||
}
|
||||
const backoff = calculateBackoff(action.attempts);
|
||||
if (action.lastAttemptAt) {
|
||||
const elapsed = (options.now?.() ?? Date.now()) - action.lastAttemptAt;
|
||||
if (elapsed < backoff) return; // not time yet
|
||||
}
|
||||
|
||||
await markInFlight(action.id);
|
||||
try {
|
||||
const dispatchResult = await dispatcher(action.actionName, action.payload, action.id);
|
||||
if (dispatchResult.ok) {
|
||||
await markSynced(action.id);
|
||||
result.synced += 1;
|
||||
} else if ("conflict" in dispatchResult) {
|
||||
await markConflict(action.id, dispatchResult.conflict);
|
||||
result.conflicts += 1;
|
||||
} else if ("error" in dispatchResult) {
|
||||
await markFailed(action.id, dispatchResult.error);
|
||||
try {
|
||||
await markInFlight(action.id);
|
||||
const dispatchResult = await dispatcher(action.actionName, action.payload, action.id);
|
||||
if (dispatchResult.ok) {
|
||||
await markSynced(action.id);
|
||||
result.synced += 1;
|
||||
} else if ("conflict" in dispatchResult) {
|
||||
await markConflict(action.id, dispatchResult.conflict);
|
||||
result.conflicts += 1;
|
||||
} else if ("error" in dispatchResult) {
|
||||
await markFailed(action.id, dispatchResult.error);
|
||||
result.failed += 1;
|
||||
}
|
||||
} catch (err) {
|
||||
// A single poisoned record (IDB closed, quota, etc.) must not abort
|
||||
// the whole sync pass. Swallow the secondary failure with a warn so
|
||||
// it stays observable in dev.
|
||||
const message = err instanceof Error ? err.message : String(err);
|
||||
try {
|
||||
await markFailed(action.id, message);
|
||||
} catch (innerErr) {
|
||||
console.warn("[offline-sync] markFailed threw for", action.id, innerErr);
|
||||
}
|
||||
result.failed += 1;
|
||||
}
|
||||
} catch (err) {
|
||||
// A single poisoned record (IDB closed, quota, etc.) must not abort
|
||||
// the whole sync pass. Swallow the secondary failure with a warn so
|
||||
// it stays observable in dev.
|
||||
const message = err instanceof Error ? err.message : String(err);
|
||||
try {
|
||||
await markFailed(action.id, message);
|
||||
} catch (innerErr) {
|
||||
console.warn("[offline-sync] markFailed threw for", action.id, innerErr);
|
||||
}
|
||||
result.failed += 1;
|
||||
}
|
||||
}
|
||||
})
|
||||
);
|
||||
return result;
|
||||
})();
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user