feat: Improve error handling for HTTP 400 and network issues in browser navigation

This commit is contained in:
2025-11-04 22:55:58 +01:00
parent f32c1bc039
commit 9733c5698b
3 changed files with 56 additions and 61 deletions

View File

@@ -52,11 +52,12 @@ class Browser {
'--ignore-ssl-errors'
]
// Minimal Linux fixes for DNS/network issues without detection risk
// Only adds essential stability flags that don't trigger bot detection
// Linux stability fixes without detection risk
const linuxStabilityArgs = isLinux ? [
'--disable-dev-shm-usage',
'--disable-software-rasterizer'
'--disable-software-rasterizer',
'--disable-http-cache',
'--disk-cache-size=1'
] : []
browser = await playwright.chromium.launch({

View File

@@ -194,10 +194,15 @@ export default class BrowserUtil {
const $ = load(html)
const isNetworkError = $('body.neterror').length
const hasHttp400Error = html.includes('HTTP ERROR 400') ||
html.includes('This page isn\'t working') ||
html.includes('Cette page ne fonctionne pas')
if (isNetworkError) {
this.bot.log(this.bot.isMobile, 'RELOAD-BAD-PAGE', 'Bad page detected, reloading!')
await page.reload()
if (isNetworkError || hasHttp400Error) {
const errorType = hasHttp400Error ? 'HTTP 400' : 'network error'
this.bot.log(this.bot.isMobile, 'RELOAD-BAD-PAGE', `Bad page detected (${errorType}), reloading!`)
await page.reload({ waitUntil: 'domcontentloaded' })
await this.bot.utils.wait(1500)
}
} catch (error) {