Rocky_Mountain_Vending/.pnpm-store/v10/files/8e/36ebb160b329af1197cbc2647473c3971aa47843c21dabee162b25e7c4cdfc8a3c7de59f66edbe803d29e9d6b28491a7e7deb62f13a22f02fd19d679c24b5d
DMleadgen 46d973904b
Initial commit: Rocky Mountain Vending website
Next.js website for Rocky Mountain Vending company featuring:
- Product catalog with Stripe integration
- Service areas and parts pages
- Admin dashboard with Clerk authentication
- SEO optimized pages with JSON-LD structured data

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-12 16:22:15 -07:00

33 lines
No EOL
1.6 KiB
Text

import { useEffect } from 'react';
import { createHrefFromUrl } from './router-reducer/create-href-from-url';
export function handleHardNavError(error) {
if (error && typeof window !== 'undefined' && window.next.__pendingUrl && createHrefFromUrl(new URL(window.location.href)) !== createHrefFromUrl(window.next.__pendingUrl)) {
console.error(`Error occurred during navigation, falling back to hard navigation`, error);
window.location.href = window.next.__pendingUrl.toString();
return true;
}
return false;
}
export function useNavFailureHandler() {
if (process.env.__NEXT_APP_NAV_FAIL_HANDLING) {
// this if is only for DCE of the feature flag not conditional
// eslint-disable-next-line react-hooks/rules-of-hooks
useEffect(()=>{
const uncaughtExceptionHandler = (evt)=>{
const error = 'reason' in evt ? evt.reason : evt.error;
// if we have an unhandled exception/rejection during
// a navigation we fall back to a hard navigation to
// attempt recovering to a good state
handleHardNavError(error);
};
window.addEventListener('unhandledrejection', uncaughtExceptionHandler);
window.addEventListener('error', uncaughtExceptionHandler);
return ()=>{
window.removeEventListener('error', uncaughtExceptionHandler);
window.removeEventListener('unhandledrejection', uncaughtExceptionHandler);
};
}, []);
}
}
//# sourceMappingURL=nav-failure-handler.js.map