From e2e384c8e6173953327a8e174f4b0e43e7a390c7 Mon Sep 17 00:00:00 2001 From: miga-heygen Date: Wed, 16 Sep 2026 20:46:00 -0400 Subject: [PATCH] test(producer): widen the rootBodyMismatch diagnostic to compare import paths MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Still not a real fix. The previous diagnostic (ca4e73983) proved the imported HTML_BODY_CSS_WIDTH_FIRST_RE has 4 capture groups in the failing CI run instead of the 2 the source and production code expect, but it used a dynamic import(), which can resolve through a different codepath than renderOrchestrator.ts's static import. This adds a static import of the same binding, a require.resolve() of the resolved file path, and a direct read of that file's own regex line, so the next run can rule in or out a static/dynamic resolution split versus a genuinely different file on disk. Locally both imports agree (2 groups, same object, correct file). To be removed once the CI answer lands. Co-Authored-By: Miguel Ángel --- .../src/services/renderOrchestrator.test.ts | 37 ++++++++++++++++--- 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/packages/producer/src/services/renderOrchestrator.test.ts b/packages/producer/src/services/renderOrchestrator.test.ts index e49d2e64c4..dc868b3d68 100644 --- a/packages/producer/src/services/renderOrchestrator.test.ts +++ b/packages/producer/src/services/renderOrchestrator.test.ts @@ -10,6 +10,9 @@ import { mergeWorkerFrames, } from "@hyperframes/engine"; import type { CompiledComposition } from "./htmlCompiler.js"; +// TEMPORARY: static import mirroring renderOrchestrator.ts's own import, to check +// whether a dynamic import() resolves the same regex object CI actually uses. +import { HTML_BODY_CSS_WIDTH_FIRST_RE as TEMP_STATIC_WIDTH_FIRST_RE } from "@hyperframes/parsers"; // Replace only the two engine functions the adaptive-retry loop uses to touch // disk; everything else (distributeFrames, types, etc.) stays real so the loop @@ -2328,8 +2331,26 @@ describe("shouldPreferSingleWorkerDrawElement (DE priority inversion)", () => { // TEMPORARY diagnostic for a CI-only failure that will not reproduce locally. // Remove once the CI log gives us enough to fix or revert. it("TEMP diagnostic: dumps intermediate regex state for the exact-match fixture", async () => { - const { HTML_BODY_CSS_WIDTH_FIRST_RE, HTML_BODY_CSS_HEIGHT_FIRST_RE } = - await import("@hyperframes/parsers"); + const { HTML_BODY_CSS_WIDTH_FIRST_RE, default: pkgDefault } = + (await import("@hyperframes/parsers")) as Record as { + HTML_BODY_CSS_WIDTH_FIRST_RE: RegExp; + default: unknown; + }; + const { createRequire } = await import("node:module"); + const require = createRequire(import.meta.url); + let resolvedPath = ""; + let resolvedFileRegexLine = ""; + try { + resolvedPath = require.resolve("@hyperframes/parsers"); + const fs = await import("node:fs"); + const contents = fs.readFileSync(resolvedPath, "utf8"); + const line = contents + .split("\n") + .find((l) => l.includes("HTML_BODY_CSS_WIDTH_FIRST_RE =")); + resolvedFileRegexLine = line ?? ""; + } catch (err) { + resolvedFileRegexLine = ``; + } const rootRe = /<[a-zA-Z][-a-zA-Z0-9]*\b[^>]*\bdata-composition-id=["'][^"']*["'][^>]*>/i; const input = html(1080, 1920, "html, body { width: 1080px; height: 1920px; }"); const rootTag = input.match(rootRe)?.[0]; @@ -2339,10 +2360,14 @@ describe("shouldPreferSingleWorkerDrawElement (DE priority inversion)", () => { rootTag, dataWidthMatch: rootTag?.match(/\bdata-width=["'](\d+)["']/i)?.[1], dataHeightMatch: rootTag?.match(/\bdata-height=["'](\d+)["']/i)?.[1], - widthFirstMatch: input.match(HTML_BODY_CSS_WIDTH_FIRST_RE), - heightFirstMatch: input.match(HTML_BODY_CSS_HEIGHT_FIRST_RE), - widthFirstReSource: HTML_BODY_CSS_WIDTH_FIRST_RE.source, - widthFirstReFlags: HTML_BODY_CSS_WIDTH_FIRST_RE.flags, + dynamicImportWidthFirstMatch: input.match(HTML_BODY_CSS_WIDTH_FIRST_RE), + staticImportWidthFirstMatch: input.match(TEMP_STATIC_WIDTH_FIRST_RE), + dynamicWidthFirstReSource: HTML_BODY_CSS_WIDTH_FIRST_RE.source, + staticWidthFirstReSource: TEMP_STATIC_WIDTH_FIRST_RE.source, + sameRegexObject: HTML_BODY_CSS_WIDTH_FIRST_RE === TEMP_STATIC_WIDTH_FIRST_RE, + hasDefaultExport: pkgDefault !== undefined, + resolvedPath, + resolvedFileRegexLine, }), ); expect(true).toBe(true);