← Back
import puppeteer from 'puppeteer-core';

const URL = process.argv[2] || 'https://poly-dev.szhub.space/';
const browser = await puppeteer.launch({
  executablePath: '/snap/bin/chromium',
  headless: 'new',
  args: ['--no-sandbox', '--disable-gpu', '--disable-dev-shm-usage'],
});
const page = await browser.newPage();

page.on('pageerror', (err) => console.log('PAGEERROR:', err.message, '\n', (err.stack || '').split('\n').slice(0, 4).join('\n')));
page.on('console', async (msg) => {
  if (!['error', 'warning'].includes(msg.type())) return;
  const parts = [];
  for (const a of msg.args()) {
    try { parts.push(JSON.stringify(await a.jsonValue())); } catch { parts.push(String(a)); }
  }
  console.log(`CONSOLE.${msg.type()}:`, msg.text(), parts.join(' '));
});
page.on('requestfailed', (r) => console.log('REQFAIL:', r.url().slice(0, 90), r.failure()?.errorText));

await page.goto(URL, { waitUntil: 'networkidle2', timeout: 30000 }).catch((e) => console.log('GOTO ERR:', e.message));
await new Promise((r) => setTimeout(r, 3000));
const rootHtml = await page.evaluate(() => document.getElementById('root')?.innerHTML?.length || 0);
console.log('root innerHTML length:', rootHtml, rootHtml === 0 ? '(EMPTY = crash)' : '(rendered)');
await browser.close();