mirror of
https://github.com/geekgeekrun/geekgeekrun.git
synced 2026-09-07 00:17:17 +08:00
fix screenshot error when page closed; catch EPIPE globally; rigister gui process
This commit is contained in:
@@ -82,5 +82,13 @@ export function openSettingWindow() {
|
||||
needCallback: true
|
||||
}
|
||||
)
|
||||
await sendToDaemon(
|
||||
{
|
||||
type: 'gui-register'
|
||||
},
|
||||
{
|
||||
needCallback: true
|
||||
}
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -52,7 +52,21 @@ export const pageMapByName: {
|
||||
|
||||
async function periodPushCurrentPageScreenshot () {
|
||||
try {
|
||||
await pushCurrentPageScreenshot(pageMapByName.boss)
|
||||
if (pageMapByName.boss?.isClosed()) {
|
||||
return
|
||||
}
|
||||
const shouldExit = await checkShouldExit()
|
||||
if (shouldExit) {
|
||||
return
|
||||
}
|
||||
try {
|
||||
await pushCurrentPageScreenshot(pageMapByName.boss)
|
||||
}
|
||||
catch (err) {
|
||||
if (err?.message?.includes(`PAGE_CLOSED`)) {
|
||||
return
|
||||
}
|
||||
}
|
||||
setTimeout(periodPushCurrentPageScreenshot, SCREENSHOT_INTERVAL_MS)
|
||||
}
|
||||
catch {}
|
||||
|
||||
@@ -3,6 +3,15 @@ import { runCommon } from './features/run-common';
|
||||
import { launchDaemon } from './flow/OPEN_SETTING_WINDOW/launch-daemon';
|
||||
import { connectToDaemon } from './flow/OPEN_SETTING_WINDOW/connect-to-daemon';
|
||||
import { randomUUID } from 'crypto';
|
||||
|
||||
// 捕获未处理的 EPIPE 错误
|
||||
process.on('uncaughtException', (err) => {
|
||||
if (err?.code === 'EPIPE' || err?.code === 'ERR_STREAM_DESTROYED') {
|
||||
return
|
||||
}
|
||||
throw err
|
||||
});
|
||||
|
||||
const isUiDev = process.env.NODE_ENV === 'development'
|
||||
const commandlineArgs = minimist(isUiDev ? process.argv.slice(2) : process.argv.slice(1))
|
||||
console.log(commandlineArgs)
|
||||
|
||||
@@ -26,6 +26,9 @@ export async function pushCurrentPageScreenshot (page) {
|
||||
}
|
||||
})
|
||||
} catch (err) {
|
||||
if (err?.message?.includes('Session closed')) {
|
||||
throw new Error(`PAGE_CLOSED`)
|
||||
}
|
||||
// 截图失败不应影响主流程
|
||||
console.warn('[READ_NO_REPLY_AUTO_REMINDER] pushCurrentPageScreenshot error', err)
|
||||
}
|
||||
@@ -38,9 +41,6 @@ export class PeriodPushCurrentPageScreenshotPlugin {
|
||||
(page) => {
|
||||
async function periodPushCurrentPageScreenshot () {
|
||||
try {
|
||||
if (!page) {
|
||||
return
|
||||
}
|
||||
if (page.isClosed()) {
|
||||
return
|
||||
}
|
||||
@@ -48,7 +48,14 @@ export class PeriodPushCurrentPageScreenshotPlugin {
|
||||
if (shouldExit) {
|
||||
return
|
||||
}
|
||||
await pushCurrentPageScreenshot(page)
|
||||
try {
|
||||
await pushCurrentPageScreenshot(page)
|
||||
}
|
||||
catch (err) {
|
||||
if (err?.message?.includes(`PAGE_CLOSED`)) {
|
||||
return
|
||||
}
|
||||
}
|
||||
setTimeout(periodPushCurrentPageScreenshot, SCREENSHOT_INTERVAL_MS)
|
||||
}
|
||||
catch {}
|
||||
|
||||
Reference in New Issue
Block a user