Deploy: 2026-06-24 15:10:09

This commit is contained in:
Hamza-Ayed
2026-06-24 15:10:09 +03:00
parent b5e5ea01c4
commit 376bb0f61c

View File

@@ -21,7 +21,11 @@ const puppeteerConfig = {
'--no-first-run', '--no-first-run',
'--disable-gpu', '--disable-gpu',
'--disable-web-security', '--disable-web-security',
'--disable-features=IsolateOrigins,site-per-process' '--disable-features=IsolateOrigins,site-per-process',
'--disable-background-timer-throttling',
'--disable-backgrounding-occluded-windows',
'--disable-renderer-backgrounding',
'--user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36'
] ]
}; };
@@ -39,6 +43,25 @@ for (const p of possiblePaths) {
} }
} }
// Clean Chrome Profile Locks to prevent startup freezes
function cleanChromeLocks(sessionKey) {
const sessionPath = path.join(SESSIONS_DIR, `session-${sessionKey}`);
const lockFiles = [
path.join(sessionPath, 'SingletonLock'),
path.join(sessionPath, 'Default', 'SingletonLock')
];
for (const lockFile of lockFiles) {
try {
if (fs.existsSync(lockFile)) {
console.log(`[CLEANUP] Removing dangling lock file for ${sessionKey}: ${lockFile}`);
fs.unlinkSync(lockFile);
}
} catch (err) {
console.warn(`[CLEANUP WARNING] Could not remove lock file for ${sessionKey} (${lockFile}):`, err.message);
}
}
}
async function sendWebhook(webhook_url, payload) { async function sendWebhook(webhook_url, payload) {
try { try {
console.log(`[Webhook] Sending to ${webhook_url} | state=${payload.state}`); console.log(`[Webhook] Sending to ${webhook_url} | state=${payload.state}`);
@@ -62,6 +85,9 @@ async function startSession(session_key, webhook_url) {
console.log(`[Session] Starting ${session_key} → webhook: ${webhook_url}`); console.log(`[Session] Starting ${session_key} → webhook: ${webhook_url}`);
// Clean dangling locks from previous crashes before launching Chrome
cleanChromeLocks(session_key);
const client = new Client({ const client = new Client({
authStrategy: new LocalAuth({ authStrategy: new LocalAuth({
clientId: session_key, clientId: session_key,