const { chromium } = require('playwright');
(async () => {
  const browser = await chromium.launch({ headless: true });
  const page = await (await browser.newContext({viewport:{width:1280,height:900}})).newPage();
  const logs = [];
  page.on('console', m => logs.push(m.text()));
  page.on('pageerror', e => logs.push('PAGEERR: ' + e.message));
  await page.goto('http://127.0.0.1:8099/buy-service/1/pos', { waitUntil: 'load' }).catch(()=>{});
  await page.waitForTimeout(7000);
  // 找 data 打印 + RangeError
  const dataLog = logs.find(l => l.startsWith('data:'));
  console.log('=== data ===', dataLog ? dataLog.slice(0,400) : '(无)');
  // 看 service_selections / options 部分
  if (dataLog) {
    const m = dataLog.match(/service_selections:[^,}]+/);
    if (m) console.log('service_selections:', m[0].slice(0,200));
    const o = dataLog.match(/options:[^]]*\]/);
    if (o) console.log('options:', o[0].slice(0,200));
  }
  await browser.close();
})();
