refactor(app): restart a stuck service from the existing Restart button

This commit is contained in:
Filip Hejmowski
2026-10-19 18:40:48 +02:00
committed by Filip
Unverified
parent b5a0177cb0
commit 387718aab4
3 changed files with 13 additions and 34 deletions
-2
View File
@@ -517,8 +517,6 @@ export const dict = {
"error.page.details.label": "Error Details",
"error.page.action.restart": "Restart",
"error.page.action.reload": "Reload",
"error.page.action.restartService": "Restart Service",
"error.page.action.restartingService": "Restarting Service…",
"error.page.action.report": "Report Error",
"error.page.action.reported": "Error Reported",
"error.page.action.exportLogs": "Export Logs",
@@ -50,10 +50,6 @@ export const LocalServerStartup = {
render: () => page(desktop, startupFailure()),
}
export const LocalServerStartupWithoutRestartService = {
render: () => page({ ...desktop, restartService: undefined }, startupFailure()),
}
export const UnexpectedError = {
render: () =>
page(
+13 -28
View File
@@ -262,11 +262,11 @@ export const ErrorPage: Component<ErrorPageProps> = (props) => {
const [store, setStore] = createStore<{
actionError: string | undefined
captureException: typeof captureException | undefined
restartingService: boolean
restarting: boolean
}>({
actionError: undefined,
captureException: undefined,
restartingService: false,
restarting: false,
})
function ensureFatalErrorRecorded() {
@@ -317,16 +317,15 @@ export const ErrorPage: Component<ErrorPageProps> = (props) => {
return state?.status === "ready" || state?.status === "download-required" ? state.version : undefined
}
// A service that failed to boot stays registered, so relaunching alone would reattach to it.
const restartService = () =>
errorDescriptionKey(props.error) === "error.page.description.localServerStartup"
? platform.restartService
: undefined
async function runRestartService(restart: () => Promise<void>) {
setStore({ restartingService: true, actionError: undefined })
await restart().catch((err) => {
setStore({ restartingService: false, actionError: formatError(err, language.t) })
async function restart() {
setStore({ restarting: true, actionError: undefined })
// A service that failed to boot stays registered, so relaunching alone would reattach to it.
const service =
errorDescriptionKey(props.error) === "error.page.description.localServerStartup"
? platform.restartService
: undefined
await (service ? service() : platform.restart()).catch((err) => {
setStore({ restarting: false, actionError: formatError(err, language.t) })
})
}
@@ -368,22 +367,8 @@ export const ErrorPage: Component<ErrorPageProps> = (props) => {
label={language.t("error.page.details.label")}
hideLabel
/>
<div class="flex flex-row items-center justify-center gap-3 flex-wrap max-w-lg">
<Show when={restartService()}>
{(restart) => (
<Button
size="large"
variant={store.restartingService ? "loading" : "contrast"}
disabled={store.restartingService}
onClick={() => void runRestartService(restart())}
>
{language.t(
store.restartingService ? "error.page.action.restartingService" : "error.page.action.restartService",
)}
</Button>
)}
</Show>
<Button size="large" onClick={platform.restart}>
<div class="flex flex-row items-center justify-center gap-3 flex-wrap max-w-64">
<Button size="large" disabled={store.restarting} onClick={() => void restart()}>
{language.t(platform.platform === "web" ? "error.page.action.reload" : "error.page.action.restart")}
</Button>
<Show when={platform.platform === "desktop" && platform.exportDebugLogs}>