feat(producer): the render stream's complete event names the producer version that rendered it (#7515)

This commit is contained in:
Miguel Ángel
2026-11-10 21:12:33 +00:00
committed by GitHub
parent fd0c2337c5
commit 7afa05a782
2 changed files with 21 additions and 1 deletions
@@ -1,4 +1,4 @@
import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { Hono } from "hono";
@@ -64,4 +64,22 @@ describe("completed render reference background", () => {
});
expect(await response.json()).toMatchObject({ reference_background: { kind: "unknown" } });
});
it("names the producer version that rendered it in the stream's complete event", async () => {
state.background = undefined;
const handlers = createRenderHandlers({ rendersDir: dir });
const app = new Hono();
app.post("/render/stream", handlers.renderStream);
const stream = await app.request("/render/stream", {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({ html: "<html><body></body></html>" }),
});
const terminal = (await stream.text())
.split("\n")
.filter((line) => line.startsWith("data:"))
.map((line) => JSON.parse(line.slice(5)))
.find((event) => event.type === "complete");
const pkg = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf-8"));
expect(terminal.producerVersion).toBe(pkg.version);
});
});
+2
View File
@@ -56,6 +56,7 @@ import {
import { parseEncoderOptions } from "@hyperframes/studio-server/encoder-options";
import { createRenderRequest, renderConfigFromRequest } from "./renderRequest.js";
import { extractSafeRenderErrorCode } from "./services/safeRenderErrorCode.js";
import { readProducerVersion } from "./services/distributed/shared.js";
export { extractSafeRenderErrorCode };
@@ -931,6 +932,7 @@ export function createRenderHandlers(options: HandlerOptions = {}): RenderHandle
outcome: job.outcome ?? "completed",
warnings: job.warnings,
perf: job.perfSummary ?? null,
producerVersion: readProducerVersion(),
}),
});
} catch (error) {