mirror of
https://github.com/geekgeekrun/geekgeekrun.git
synced 2026-05-12 02:19:55 +08:00
fix ui project issue that once throw error, browser never restart; add the time gap for next time when encounter error.
This commit is contained in:
@@ -84,18 +84,14 @@ export async function mainLoop (hooks) {
|
||||
})
|
||||
hooks.puppeteerLaunched?.call()
|
||||
|
||||
page = await browser.newPage()
|
||||
sleep(2000).then(() => {
|
||||
page.bringToFront()
|
||||
})
|
||||
|
||||
page = (await browser.pages())[0]
|
||||
//set cookies
|
||||
hooks.cookieWillSet?.call(bossCookies)
|
||||
for(let i = 0; i < bossCookies.length; i++){
|
||||
await page.setCookie(bossCookies[i]);
|
||||
}
|
||||
await setDomainLocalStorage(browser, localStoragePageUrl, bossLocalStorage)
|
||||
|
||||
await page.bringToFront()
|
||||
let userInfoResponse
|
||||
await Promise.all([
|
||||
page.goto(recommendJobPageUrl, { timeout: 0 }),
|
||||
|
||||
@@ -9,6 +9,7 @@ import path from 'node:path'
|
||||
import { get__dirname } from '@geekgeekrun/utils/legacy-path.mjs';
|
||||
import JSON5 from 'json5'
|
||||
import { readConfigFile, readStorageFile } from '@geekgeekrun/geek-auto-start-chat-with-boss/runtime-file-utils.mjs'
|
||||
import { sleep } from '@geekgeekrun/utils/sleep.mjs'
|
||||
const bossCookies = readStorageFile('boss-cookies.json')
|
||||
const { groupRobotAccessToken: dingTalkAccessToken } = readConfigFile('dingtalk.json')
|
||||
|
||||
@@ -36,7 +37,12 @@ const initPlugins = (hooks) => {
|
||||
try {
|
||||
await mainLoop(hooks)
|
||||
} catch (err) {
|
||||
console.error(err)
|
||||
console.log(err)
|
||||
if (err instanceof Error && err.message.includes('LOGIN_STATUS_INVALID')) {
|
||||
process.exit(2)
|
||||
break
|
||||
}
|
||||
await sleep(3000)
|
||||
}
|
||||
}
|
||||
})()
|
||||
@@ -5,6 +5,7 @@ import { readConfigFile } from '@geekgeekrun/geek-auto-start-chat-with-boss/runt
|
||||
import * as fs from 'fs'
|
||||
import { pipeWriteRegardlessError } from '../utils/pipe'
|
||||
import { getAnyAvailablePuppeteerExecutable } from '../CHECK_AND_DOWNLOAD_DEPENDENCIES/utils/puppeteer-executable'
|
||||
import { sleep } from '@geekgeekrun/utils/sleep.mjs'
|
||||
|
||||
const { groupRobotAccessToken: dingTalkAccessToken } = readConfigFile('dingtalk.json')
|
||||
|
||||
@@ -91,9 +92,8 @@ export const runAutoChat = async () => {
|
||||
if (err instanceof Error && err.message.includes('LOGIN_STATUS_INVALID')) {
|
||||
process.exit(2)
|
||||
break
|
||||
} else {
|
||||
throw err
|
||||
}
|
||||
await sleep(3000)
|
||||
}
|
||||
}
|
||||
closeBrowserWindow()
|
||||
|
||||
Reference in New Issue
Block a user