Skip to content

Commit e2e384c

Browse files
test(producer): widen the rootBodyMismatch diagnostic to compare import paths
Still not a real fix. The previous diagnostic (ca4e739) 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 <[email protected]>
1 parent ca4e739 commit e2e384c

1 file changed

Lines changed: 31 additions & 6 deletions

File tree

‎packages/producer/src/services/renderOrchestrator.test.ts‎

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ import {
1010
mergeWorkerFrames,
1111
} from "@hyperframes/engine";
1212
import type { CompiledComposition } from "./htmlCompiler.js";
13+
// TEMPORARY: static import mirroring renderOrchestrator.ts's own import, to check
14+
// whether a dynamic import() resolves the same regex object CI actually uses.
15+
import { HTML_BODY_CSS_WIDTH_FIRST_RE as TEMP_STATIC_WIDTH_FIRST_RE } from "@hyperframes/parsers";
1316

1417
// Replace only the two engine functions the adaptive-retry loop uses to touch
1518
// disk; everything else (distributeFrames, types, etc.) stays real so the loop
@@ -2328,8 +2331,26 @@ describe("shouldPreferSingleWorkerDrawElement (DE priority inversion)", () => {
23282331
// TEMPORARY diagnostic for a CI-only failure that will not reproduce locally.
23292332
// Remove once the CI log gives us enough to fix or revert.
23302333
it("TEMP diagnostic: dumps intermediate regex state for the exact-match fixture", async () => {
2331-
const { HTML_BODY_CSS_WIDTH_FIRST_RE, HTML_BODY_CSS_HEIGHT_FIRST_RE } =
2332-
await import("@hyperframes/parsers");
2334+
const { HTML_BODY_CSS_WIDTH_FIRST_RE, default: pkgDefault } =
2335+
(await import("@hyperframes/parsers")) as Record<string, unknown> as {
2336+
HTML_BODY_CSS_WIDTH_FIRST_RE: RegExp;
2337+
default: unknown;
2338+
};
2339+
const { createRequire } = await import("node:module");
2340+
const require = createRequire(import.meta.url);
2341+
let resolvedPath = "<resolve threw>";
2342+
let resolvedFileRegexLine = "<read threw>";
2343+
try {
2344+
resolvedPath = require.resolve("@hyperframes/parsers");
2345+
const fs = await import("node:fs");
2346+
const contents = fs.readFileSync(resolvedPath, "utf8");
2347+
const line = contents
2348+
.split("\n")
2349+
.find((l) => l.includes("HTML_BODY_CSS_WIDTH_FIRST_RE ="));
2350+
resolvedFileRegexLine = line ?? "<no matching line found in resolved file>";
2351+
} catch (err) {
2352+
resolvedFileRegexLine = `<error: ${String(err)}>`;
2353+
}
23332354
const rootRe = /<[a-zA-Z][-a-zA-Z0-9]*\b[^>]*\bdata-composition-id=["'][^"']*["'][^>]*>/i;
23342355
const input = html(1080, 1920, "html, body { width: 1080px; height: 1920px; }");
23352356
const rootTag = input.match(rootRe)?.[0];
@@ -2339,10 +2360,14 @@ describe("shouldPreferSingleWorkerDrawElement (DE priority inversion)", () => {
23392360
rootTag,
23402361
dataWidthMatch: rootTag?.match(/\bdata-width=["'](\d+)["']/i)?.[1],
23412362
dataHeightMatch: rootTag?.match(/\bdata-height=["'](\d+)["']/i)?.[1],
2342-
widthFirstMatch: input.match(HTML_BODY_CSS_WIDTH_FIRST_RE),
2343-
heightFirstMatch: input.match(HTML_BODY_CSS_HEIGHT_FIRST_RE),
2344-
widthFirstReSource: HTML_BODY_CSS_WIDTH_FIRST_RE.source,
2345-
widthFirstReFlags: HTML_BODY_CSS_WIDTH_FIRST_RE.flags,
2363+
dynamicImportWidthFirstMatch: input.match(HTML_BODY_CSS_WIDTH_FIRST_RE),
2364+
staticImportWidthFirstMatch: input.match(TEMP_STATIC_WIDTH_FIRST_RE),
2365+
dynamicWidthFirstReSource: HTML_BODY_CSS_WIDTH_FIRST_RE.source,
2366+
staticWidthFirstReSource: TEMP_STATIC_WIDTH_FIRST_RE.source,
2367+
sameRegexObject: HTML_BODY_CSS_WIDTH_FIRST_RE === TEMP_STATIC_WIDTH_FIRST_RE,
2368+
hasDefaultExport: pkgDefault !== undefined,
2369+
resolvedPath,
2370+
resolvedFileRegexLine,
23462371
}),
23472372
);
23482373
expect(true).toBe(true);

0 commit comments

Comments
 (0)