debug(schematics): add HTML logging for download page diagnosis
All checks were successful
Deploy to Docker / deploy (push) Successful in 1m28s
All checks were successful
Deploy to Docker / deploy (push) Successful in 1m28s
Add debug logging to dump page titles, HTML lengths, and snippets when the schematic download page is loaded. Also switch to waitUntil: 'load' and add 3s delay for async JS execution. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -193,14 +193,23 @@ export async function downloadSchematic(projectUrl, timeoutMs = 60000) {
|
|||||||
// Step 2: Navigate to download page (worldmap has the Schemagic embed with the real URL)
|
// Step 2: Navigate to download page (worldmap has the Schemagic embed with the real URL)
|
||||||
const downloadPageUrl = projectUrl.replace(/\/?$/, '/download/worldmap/');
|
const downloadPageUrl = projectUrl.replace(/\/?$/, '/download/worldmap/');
|
||||||
log(TAG, `Navigating to download page: ${downloadPageUrl}`);
|
log(TAG, `Navigating to download page: ${downloadPageUrl}`);
|
||||||
await page.goto(downloadPageUrl, { waitUntil: 'domcontentloaded', timeout: timeoutMs });
|
await page.goto(downloadPageUrl, { waitUntil: 'load', timeout: timeoutMs });
|
||||||
await waitForCloudflare(page, timeoutMs);
|
await waitForCloudflare(page, timeoutMs);
|
||||||
|
// Give JS time to execute (Schemagic embeds may load async)
|
||||||
|
await page.waitForTimeout(3000);
|
||||||
|
|
||||||
// Step 3: Extract schematic URL from Schemagic.load() JS call or <a download> element
|
// Step 3: Extract schematic URL from Schemagic.load() JS call or <a download> element
|
||||||
let schematicUrl = null;
|
let schematicUrl = null;
|
||||||
|
|
||||||
// 3a: Look for Schemagic.load({ schematic: "https://...resource_media/schematic/..." })
|
// 3a: Look for Schemagic.load({ schematic: "https://...resource_media/schematic/..." })
|
||||||
const html = await page.content();
|
const html = await page.content();
|
||||||
|
// Debug: Log page title and HTML snippet to diagnose extraction failures
|
||||||
|
const pageTitle = await page.title();
|
||||||
|
log(TAG, `Download page title: "${pageTitle}", HTML length: ${html.length}`);
|
||||||
|
log(TAG, `HTML snippet (first 500): ${html.slice(0, 500).replace(/\n/g, ' ')}`);
|
||||||
|
// Check for any download-related links
|
||||||
|
const allHrefs = html.match(/href="[^"]*download[^"]*"/gi) || [];
|
||||||
|
log(TAG, `Download-related hrefs found: ${allHrefs.length} — ${allHrefs.slice(0, 5).join(', ')}`);
|
||||||
const schemagicMatch = html.match(/Schemagic\.load\s*\(\s*\{[^}]*schematic:\s*"([^"]+)"/);
|
const schemagicMatch = html.match(/Schemagic\.load\s*\(\s*\{[^}]*schematic:\s*"([^"]+)"/);
|
||||||
if (schemagicMatch) {
|
if (schemagicMatch) {
|
||||||
schematicUrl = schemagicMatch[1];
|
schematicUrl = schemagicMatch[1];
|
||||||
@@ -232,10 +241,14 @@ export async function downloadSchematic(projectUrl, timeoutMs = 60000) {
|
|||||||
if (!schematicUrl) {
|
if (!schematicUrl) {
|
||||||
const schematicPageUrl = projectUrl.replace(/\/?$/, '/download/schematic/');
|
const schematicPageUrl = projectUrl.replace(/\/?$/, '/download/schematic/');
|
||||||
log(TAG, `Trying schematic download page: ${schematicPageUrl}`);
|
log(TAG, `Trying schematic download page: ${schematicPageUrl}`);
|
||||||
await page.goto(schematicPageUrl, { waitUntil: 'domcontentloaded', timeout: timeoutMs });
|
await page.goto(schematicPageUrl, { waitUntil: 'load', timeout: timeoutMs });
|
||||||
await waitForCloudflare(page, timeoutMs);
|
await waitForCloudflare(page, timeoutMs);
|
||||||
|
await page.waitForTimeout(3000);
|
||||||
|
|
||||||
const schematicHtml = await page.content();
|
const schematicHtml = await page.content();
|
||||||
|
const schPageTitle = await page.title();
|
||||||
|
log(TAG, `Schematic page title: "${schPageTitle}", HTML length: ${schematicHtml.length}`);
|
||||||
|
log(TAG, `Schematic page HTML snippet (first 500): ${schematicHtml.slice(0, 500).replace(/\n/g, ' ')}`);
|
||||||
const schematicPageMatch = schematicHtml.match(/Schemagic\.load\s*\(\s*\{[^}]*schematic:\s*"([^"]+)"/);
|
const schematicPageMatch = schematicHtml.match(/Schemagic\.load\s*\(\s*\{[^}]*schematic:\s*"([^"]+)"/);
|
||||||
if (schematicPageMatch) {
|
if (schematicPageMatch) {
|
||||||
schematicUrl = schematicPageMatch[1];
|
schematicUrl = schematicPageMatch[1];
|
||||||
|
|||||||
Reference in New Issue
Block a user