-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Show a nicer UI when minifront can't connect to the extension, and for other errors #752
Changes from 7 commits
288bd30
f078c7a
2d09088
0295b3b
1ccf868
a37a2d1
c68fc47
ece76b4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { SplashPage } from '@penumbra-zone/ui'; | ||
import { HeadTag } from './metadata/head-tag'; | ||
|
||
const NODE_STATUS_PAGE_URL = | ||
window.location.hostname === 'localhost' ? 'http://localhost:5174' : '/'; | ||
|
||
export const ExtensionUnavailable = () => { | ||
return ( | ||
<> | ||
<HeadTag /> | ||
|
||
<SplashPage title='Penumbra extension unavailble'> | ||
<p className='mb-2'>We can't currently connect to the Penumbra extension.</p> | ||
<p className='mb-2'> | ||
This page may have been left open for too long, causing a timeout. Please reload this page | ||
and see if that fixes the issue. | ||
</p> | ||
<p> | ||
If it doesn't, the RPC node that you're connected to could be down. Check{' '} | ||
<a href={NODE_STATUS_PAGE_URL} className='underline'> | ||
the node's status page | ||
</a>{' '} | ||
and, if it is down, consider switching to a different RPC URL in the Penumbra | ||
extension's settings. | ||
</p> | ||
</SplashPage> | ||
Comment on lines
+12
to
+26
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. these cases should be readily distinguishable by the error message |
||
</> | ||
); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { SplashPage } from '@penumbra-zone/ui'; | ||
|
||
export const NotFound = () => { | ||
return <SplashPage title='404'>That page could not be found. </SplashPage>; | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,25 @@ | ||
import { useRouteError } from 'react-router-dom'; | ||
import { isRouteErrorResponse, useRouteError } from 'react-router-dom'; | ||
import { PraxNotConnectedError } from '@penumbra-zone/client'; | ||
import { ExtensionNotConnected } from '../extension-not-connected'; | ||
import { NotFound } from '../not-found'; | ||
import { ExtensionUnavailable } from '../extension-unavailable'; | ||
import { Code, ConnectError } from '@connectrpc/connect'; | ||
import { SplashPage } from '@penumbra-zone/ui'; | ||
|
||
export const ErrorBoundary = () => { | ||
const error = useRouteError(); | ||
|
||
if (error instanceof ConnectError && error.code === Code.Unavailable) { | ||
return <ExtensionUnavailable />; | ||
} | ||
if (error instanceof PraxNotConnectedError) return <ExtensionNotConnected />; | ||
if (isRouteErrorResponse(error) && error.status === 404) return <NotFound />; | ||
|
||
console.error(error); | ||
console.error('ErrorBoundary caught error:', error); | ||
|
||
return ( | ||
<div className='text-red'> | ||
<h1 className='text-xl'>{String(error)}</h1> | ||
</div> | ||
<SplashPage title='Uh-oh!' description='Looks like there was an error.'> | ||
{String(error)} | ||
</SplashPage> | ||
); | ||
turbocrime marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,6 @@ | ||
import { viewClient } from '../clients'; | ||
|
||
export const getChainId = async (): Promise<string> => { | ||
export const getChainId = async (): Promise<string | undefined> => { | ||
const { parameters } = await viewClient.appParameters({}); | ||
if (!parameters?.chainId) throw new Error('No chainId in response'); | ||
|
||
return parameters.chainId; | ||
return parameters?.chainId; | ||
Comment on lines
+3
to
+5
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a little change @turbocrime suggested. We don't need to throw if the chain ID doesn't come back from the server. |
||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,14 @@ | ||
import { SplashPage } from '@penumbra-zone/ui'; | ||
import { useRouteError } from 'react-router-dom'; | ||
|
||
export const ErrorBoundary = () => { | ||
const error = useRouteError(); | ||
|
||
console.error(error); | ||
console.error('ErrorBoundary caught error:', error); | ||
|
||
return ( | ||
<div className='text-red'> | ||
<h1 className='text-xl'>{String(error)}</h1> | ||
</div> | ||
<SplashPage title='Uh-oh!' description='Looks like there was an error.'> | ||
turbocrime marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{String(error)} | ||
</SplashPage> | ||
); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this probably needs a .env and webpack define
edit: i guess this is vite
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually, it seems to be the same as the grpc endpoint uri
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is tricky... we'd want to define the port number in .env, you mean, right? that would mean putting
5174
innode-status
's.env
file, and then importing it from minifront? (Cause I assume we'd also want to use the.env
value innode-status
'spackage.json
dev
script.)