{"record":{"id":"46cdafdd46e6a7fc","repo":"chenglou/pretext","slug":"batchreport-message-pre-wrap-batch-failed","errorCode":null,"errorMessage":"${batchReport.message ?? 'pre-wrap batch failed'}","messagePattern":"\\$\\{batchReport\\.message \\?\\? 'pre-wrap batch failed'\\}","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/pre-wrap-check.ts","lineNumber":130,"sourceCode":"    serverProcess = pageServer.process\n    const requestId = `${browser}-${Date.now()}-${Math.random().toString(36).slice(2)}`\n    const reportServer = await startPostedReportServer<ProbeBatchReport>(requestId)\n\n    try {\n      const url =\n        `${pageServer.baseUrl}/probe?batch=pre-wrap` +\n        `&requestId=${encodeURIComponent(requestId)}` +\n        `&reportEndpoint=${encodeURIComponent(reportServer.endpoint)}`\n      const batchReport = await loadPostedReport(\n        session,\n        url,\n        () => reportServer.waitForReport(null),\n        requestId,\n        reportBrowser,\n        timeoutMs,\n      )\n      if (batchReport.status === 'error') {\n        throw new Error(batchReport.message ?? 'pre-wrap batch failed')\n      }\n\n      const batchResults = batchReport.results ?? []\n      const reportsByLabel = new Map(batchResults.map(result => [result.label, result.report]))\n      for (const testCase of PRE_WRAP_ORACLE_CASES) {\n        const report = reportsByLabel.get(testCase.label)\n        if (report === undefined) {\n          throw new Error(`Missing pre-wrap result for ${testCase.label}`)\n        }\n        printCaseResult(browser, testCase, report)\n        if (!reportIsExact(report)) ok = false\n      }\n    } finally {\n      reportServer.close()\n    }\n  } finally {\n    session?.close()\n    serverProcess?.kill()","sourceCodeStart":112,"sourceCodeEnd":148,"githubUrl":"https://github.com/chenglou/pretext/blob/ac49b09b7d83ede19581fa94a8b892b07d309baf/scripts/pre-wrap-check.ts#L112-L148","documentation":"runBrowser() inspects the posted ProbeBatchReport from the /probe?batch=pre-wrap page; if status is 'error', it re-throws wrapped with batchReport.message (or the generic 'pre-wrap batch failed'). The originating failure is inside the browser probe page, surfaced by this CLI.","triggerScenarios":"The pre-wrap probe page threw during measurement, could not measure a case (e.g. tab/space/hard-break handling), or explicitly reported status='error'. Common with an unhealthy page server, a throttled/backgrounded tab, or a regression in the probe page.","commonSituations":"Transient automation flakiness, dev server not running, stale tabs/servers, or a real regression in pre-wrap handling.","solutions":["Read the wrapped batchReport.message for the browser-side root cause.","Confirm the probe page server is healthy; suspect stale tabs/servers before assuming an engine bug (per repo guidance).","Raise `--timeout=` if the message indicates a measurement timeout.","Reproduce the failing case on the diagnostic /probe page to localize."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":"const isBatchError = (r: { status?: string }): boolean => r.status === 'error'","tryCatchPattern":"try {\n  await runBrowser(browser, port)\n} catch (e) {\n  const msg = e instanceof Error ? e.message : String(e)\n  if (msg.includes('pre-wrap batch failed') || /pre-wrap/i.test(msg)) {\n    console.error(`Probe batch error for ${browser}. Suspect stale tabs/servers first; see message: ${msg}`)\n    process.exit(1)\n  }\n  throw e\n}","preventionTips":["Don't run concurrent automation jobs against the same browser (single-owner lock).","Suspect stale tabs/servers first; raise --timeout before assuming a regression."],"tags":["browser-automation","probe","pre-wrap","diagnostics"],"backgroundTag":null,"analyzedSha":"ac49b09b7d83ede19581fa94a8b892b07d309baf","analyzedAt":"2026-08-12T17:03:16.263Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}