mirror of
https://github.com/anomalyco/opencode.git
synced 2026-05-30 03:54:59 +00:00
fix: surface desktop renderer errors in logs
This commit is contained in:
parent
58ab95e32c
commit
6f2a6356ed
2 changed files with 50 additions and 0 deletions
|
|
@ -339,6 +339,7 @@ export function DialogLocalServer() {
|
|||
}
|
||||
|
||||
function requestError(language: ReturnType<typeof useLanguage>, err: unknown) {
|
||||
console.error("Local Server request failed", err)
|
||||
showToast({
|
||||
variant: "error",
|
||||
title: language.t("common.requestFailed"),
|
||||
|
|
|
|||
|
|
@ -69,6 +69,14 @@ function setupApp() {
|
|||
ensureLoopbackNoProxy()
|
||||
app.commandLine.appendSwitch("proxy-bypass-list", "<-loopback>")
|
||||
|
||||
process.on("uncaughtException", (error) => {
|
||||
logger.error("main process uncaught exception", error)
|
||||
})
|
||||
|
||||
process.on("unhandledRejection", (reason) => {
|
||||
logger.error("main process unhandled rejection", reason)
|
||||
})
|
||||
|
||||
if (!app.requestSingleInstanceLock()) {
|
||||
app.quit()
|
||||
return
|
||||
|
|
@ -227,6 +235,7 @@ async function initialize() {
|
|||
const show = await Promise.race([loadingTask.then(() => false), delay(1_000).then(() => true)])
|
||||
if (show) {
|
||||
overlay = createLoadingWindow(globals)
|
||||
wireWindowDiagnostics(overlay, "loading")
|
||||
await delay(1_000)
|
||||
}
|
||||
}
|
||||
|
|
@ -239,11 +248,51 @@ async function initialize() {
|
|||
}
|
||||
|
||||
mainWindow = createMainWindow(globals)
|
||||
wireWindowDiagnostics(mainWindow, "main")
|
||||
wireMenu()
|
||||
|
||||
overlay?.close()
|
||||
}
|
||||
|
||||
function wireWindowDiagnostics(win: BrowserWindow, label: string) {
|
||||
win.webContents.on("console-message", (_event, level, message, line, sourceId) => {
|
||||
const payload = { level, message, line, sourceId }
|
||||
if (level >= 3) {
|
||||
logger.error(`${label} renderer console`, payload)
|
||||
return
|
||||
}
|
||||
if (level >= 2) {
|
||||
logger.warn(`${label} renderer console`, payload)
|
||||
return
|
||||
}
|
||||
logger.log(`${label} renderer console`, payload)
|
||||
})
|
||||
|
||||
win.webContents.on("did-fail-load", (_event, errorCode, errorDescription, validatedURL, isMainFrame) => {
|
||||
logger.error(`${label} renderer failed load`, {
|
||||
errorCode,
|
||||
errorDescription,
|
||||
validatedURL,
|
||||
isMainFrame,
|
||||
})
|
||||
})
|
||||
|
||||
win.webContents.on("render-process-gone", (_event, details) => {
|
||||
logger.error(`${label} renderer process gone`, details)
|
||||
})
|
||||
|
||||
win.webContents.on("preload-error", (_event, path, error) => {
|
||||
logger.error(`${label} preload error`, {
|
||||
path,
|
||||
error: error instanceof Error ? (error.stack ?? error.message) : String(error),
|
||||
})
|
||||
})
|
||||
|
||||
win.on("unresponsive", () => {
|
||||
logger.error(`${label} window became unresponsive`)
|
||||
})
|
||||
}
|
||||
|
||||
function wireMenu() {
|
||||
if (!mainWindow) return
|
||||
createMenu({
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue