Commit 5cf9e84d authored by Moody Salem's avatar Moody Salem Committed by GitHub

fix(error handling): try reloading the app when encountering a javascript error (#3435)

parent c0bdb8db
...@@ -49,6 +49,11 @@ type ErrorBoundaryState = { ...@@ -49,6 +49,11 @@ type ErrorBoundaryState = {
const IS_UNISWAP = window.location.hostname === 'app.uniswap.org' const IS_UNISWAP = window.location.hostname === 'app.uniswap.org'
async function updateServiceWorker(): Promise<void> {
const ready = await navigator.serviceWorker.ready
await ready.update()
}
export default class ErrorBoundary extends React.Component<unknown, ErrorBoundaryState> { export default class ErrorBoundary extends React.Component<unknown, ErrorBoundaryState> {
constructor(props: unknown) { constructor(props: unknown) {
super(props) super(props)
...@@ -56,6 +61,13 @@ export default class ErrorBoundary extends React.Component<unknown, ErrorBoundar ...@@ -56,6 +61,13 @@ export default class ErrorBoundary extends React.Component<unknown, ErrorBoundar
} }
static getDerivedStateFromError(error: Error): ErrorBoundaryState { static getDerivedStateFromError(error: Error): ErrorBoundaryState {
updateServiceWorker()
.then(() => {
window.location.reload()
})
.catch((error) => {
console.error('Failed to update service worker', error)
})
return { error } return { error }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment