Intelligence, Advanced Charting & Trading Platform
diagnostics/chartnova-blank-screen-2026-10-15
diagnostics/chartnova-blank-screen-2026-10-15
diagnostics/chartnova-stage2-v27-preview-2026-10-15
docs/chartnova-stage1-reconcile-manifest-2026-10-15
feature/chartnova-ios-widget
feature/chartnova-light-catalog-lazy-series-2026-10-15
feature/chartnova-market-terminal
feature/chartnova-multimarket-chart-ws-foundation
feature/chartnova-neon-direct-history
feature/chartnova-neon-history
feature/paper-trading-risk-controls-2026-10-14
fix/alpha-vantage-live-payload
fix/chartnova-progressive-loading-2026-10-15
fix/live-proof-runner-cwd-2026-10-14
foundation/phase-0
foundation/postgres-core
main
ops/chartnova-emergency-rollback-2026-10-15
phase-1/candle-builder
phase-1/data-proof-artifact
phase-1/data-proof-metrics
phase-1/data-proof-report
phase-1/external-gates-state
phase-1/gold-api-fallback
phase-1/ingestion-pipeline
phase-1/live-proof-runner
phase-1/market-calendar
phase-1/market-domain
phase-1/neon-live-proof
phase-1/persistence-contract
phase-1/postgres-ci
phase-1/provider-adapters
phase-1/provider-recovery
phase-1/quality-propagation
phase-1/spike-detection
phase-1/xau-provider-adapter
risk/chartnova-alert-runtime-atomic-2026-10-22
risk/chartnova-atomic-outbox-2026-10-22
risk/chartnova-seven-track-safety-2026-10-21
safety/p0-triage-2026-10-13
| 1 | import { chromium } from 'playwright'; |
| 2 | import { Script } from 'node:vm'; |
| 3 | |
| 4 | const HOST = 'https://app.chartnova.ir/'; |
| 5 | const TIMEOUT = 25_000; |
| 6 | const report = { target: HOST, checkedAt: new Date().toISOString(), html: {}, sessions: [] }; |
| 7 | const safe = err => String(err?.message ?? err).slice(0, 400); |
| 8 | let failed = false; |
| 9 | |
| 10 | // External GET only, no account sign-in, no credential collection, no cloud mutations. |
| 11 | try { |
| 12 | const response = await fetch(HOST, { signal: AbortSignal.timeout(TIMEOUT), headers: { 'Cache-Control': 'no-cache' } }); |
| 13 | const html = await response.text(); |
| 14 | const match = [...html.matchAll(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi)]; |
| 15 | report.html = { |
| 16 | status: response.status, type: response.headers.get('content-type'), |
| 17 | bytes: html.length, inlineScripts: match.length, |
| 18 | hasVisibleAppMarkup: html.includes('class="shell"'), |
| 19 | cacheControl: response.headers.get('cache-control'), |
| 20 | }; |
| 21 | for (const [i, item] of match.entries()) { |
| 22 | if (item[1].includes('src=')) continue; |
| 23 | try { new Script(item[2], { filename: 'production-inline-' + i + '.js' }); } |
| 24 | catch (err) { failed = true; report.html.syntaxError = safe(err); } |
| 25 | } |
| 26 | if (!response.ok || !report.html.hasVisibleAppMarkup) failed = true; |
| 27 | } catch (e) { failed = true; report.html.networkError = safe(e); } |
| 28 | |
| 29 | const browser = await chromium.launch({ headless: true }); |
| 30 | try { |
| 31 | const suites = [ |
| 32 | { name: 'desktop-sw-blocked', viewport: { width: 1366, height: 768 }, mobile: false, serviceWorkers: 'block' }, |
| 33 | { name: 'mobile-sw-blocked', viewport: { width: 390, height: 844 }, mobile: true, serviceWorkers: 'block' }, |
| 34 | { name: 'mobile-sw-allowed', viewport: { width: 390, height: 844 }, mobile: true, serviceWorkers: 'allow' } |
| 35 | ]; |
| 36 | for (const spec of suites) { |
| 37 | const context = await browser.newContext({ |
| 38 | viewport: spec.viewport, isMobile: spec.mobile, hasTouch: spec.mobile, |
| 39 | serviceWorkers: spec.serviceWorkers, |
| 40 | }); |
| 41 | const page = await context.newPage(); |
| 42 | const result = { scenario: spec.name, jsErrors: [], consoleErrors: [], failedRequests: [] }; |
| 43 | page.on('pageerror', err => result.jsErrors.push(safe(err))); |
| 44 | page.on('console', msg => { if (msg.type() === 'error') result.consoleErrors.push(msg.text().slice(0, 260)); }); |
| 45 | page.on('requestfailed', req => { if (result.failedRequests.length < 10) result.failedRequests.push({ path: new URL(req.url()).pathname, reason: req.failure()?.errorText }); }); |
| 46 | try { |
| 47 | const response = await page.goto(HOST, { waitUntil: 'domcontentloaded', timeout: TIMEOUT }); |
| 48 | result.httpStatus = response?.status() ?? null; |
| 49 | await page.waitForTimeout(3500); |
| 50 | result.ui = await page.evaluate(async () => { |
| 51 | const shell = document.querySelector('.shell'); |
| 52 | const main = document.querySelector('main'); |
| 53 | const box = shell?.getBoundingClientRect(); |
| 54 | const css = shell ? getComputedStyle(shell) : null; |
| 55 | let serviceWorkerController = false; |
| 56 | let cacheKeys = []; |
| 57 | try { |
| 58 | serviceWorkerController = !!navigator.serviceWorker?.controller; |
| 59 | cacheKeys = ('caches' in window) ? await caches.keys() : []; |
| 60 | } catch {} |
| 61 | return { |
| 62 | readyState: document.readyState, |
| 63 | title: document.title, bodyChars: document.body?.innerText.length ?? 0, |
| 64 | shellExists: !!shell, shellWidth: box?.width ?? 0, shellHeight: box?.height ?? 0, |
| 65 | shellDisplay: css?.display ?? null, shellVisibility: css?.visibility ?? null, |
| 66 | mainExists: !!main, mainTextChars: main?.innerText.length ?? 0, |
| 67 | initialDashboardVisible: document.getElementById('dashboard')?.hidden === false, |
| 68 | status: document.getElementById('status')?.innerText.slice(0, 180) ?? null, |
| 69 | serviceWorkerController, cacheKeys |
| 70 | }; |
| 71 | }); |
| 72 | if (result.httpStatus !== 200 || !result.ui?.shellExists || result.ui?.shellWidth < 50 || result.ui?.bodyChars < 90 || result.jsErrors.length) failed = true; |
| 73 | } catch (err) { |
| 74 | failed = true; result.navigationError = safe(err); |
| 75 | } |
| 76 | report.sessions.push(result); |
| 77 | await context.close(); |
| 78 | } |
| 79 | } finally { await browser.close(); } |
| 80 | console.log('CHARTNOVA_PUBLIC_BROWSER_DIAGNOSTIC ' + JSON.stringify(report)); |
| 81 | if (failed) process.exitCode = 1; |