enhance the rerun logic for read no reply auto reminder

This commit is contained in:
geekgeekrun
2024-11-23 13:30:17 +08:00
parent b798da0bfb
commit abfd9d71e3
@@ -14,7 +14,8 @@ let browser: null | Browser = null
const mainLoop = async () => { const mainLoop = async () => {
if (browser) { if (browser) {
try { try {
await browser?.close() const cp = browser.process()
cp?.kill('SIGKILL')
} catch { } catch {
// //
} finally { } finally {
@@ -187,9 +188,14 @@ export async function runEntry() {
try { try {
await mainLoop() await mainLoop()
} catch (err) { } catch (err) {
await browser?.close() console.error(err)
try {
await pageMapByName['boss']?.close()
} catch {
//
}
} finally { } finally {
browser = null pageMapByName['boss'] = null
await sleep(rerunInterval) await sleep(rerunInterval)
} }
} }
@@ -198,3 +204,12 @@ export async function runEntry() {
} }
attachListenerForKillSelfOnParentExited() attachListenerForKillSelfOnParentExited()
process.once('uncaughtException', (error) => {
console.error('uncaughtException', error)
process.exit(1)
})
process.once('unhandledRejection', (error) => {
console.log('unhandledRejection', error)
process.exit(1)
})