fix(producer): a taken file-server port fails the render, and the late grading test runs in its lane (#6561)

* fix(producer): a taken file-server port fails the render, and the late grading test runs in its lane

* test(producer): run the taken-port file-server test under Node, where listen errors are events

* test(producer): every *.integration.test.ts must sit in the integration lane

* fix(producer): drop the explanatory comment on the file-server error handler
This commit is contained in:
Miguel Ángel
2026-10-27 14:31:17 +00:00
committed by GitHub
parent d6e16aa187
commit 9d9bdd23ba
4 changed files with 41 additions and 1 deletions
@@ -18,6 +18,7 @@
"src/services/distributed/renderChunk.test.ts",
"src/services/fileServer.test.ts",
"src/services/fileServer.file-race.test.ts",
"src/services/fileServer.listenError.test.ts",
"src/services/healthWorker.test.ts",
"src/services/scriptFailureAttribution.test.ts",
"src/services/hyperframeLint.file-race.test.ts",
@@ -26,9 +27,11 @@
"src/services/htmlCompiler.naturalDuration.test.ts",
"src/services/htmlCompiler.probeCount.test.ts",
"src/services/htmlCompiler.variableMedia.test.ts",
"src/services/render/audioPadTrim.integration.test.ts",
"src/services/render/deliveryRender.integration.test.ts",
"src/services/render/firstFrameStartingState.integration.test.ts",
"src/services/render/hlsRender.integration.test.ts",
"src/services/render/lateVisibleImageGrading.integration.test.ts",
"src/services/render/motionBlurVideo.integration.test.ts",
"src/services/render/renderCancel.integration.test.ts",
"src/services/render/segmentedColorGrading.integration.test.ts",
@@ -68,6 +68,17 @@ describe("producer test classification", () => {
});
});
it("runs every *.integration.test.ts in the integration lane, where sockets and real renders are allowed", () => {
const stray = discoverProducerTests().filter(
({ file, lane }) => file.endsWith(".integration.test.ts") && lane !== "integration",
);
assert.deepEqual(
stray.map(({ file }) => file),
[],
"add each to scripts/integration-tests.json",
);
});
it("selects the distributed smoke and playback parity tests as integration tests", () => {
const files = [
"tests/distributed/_smoke/webm-concat-copy.test.ts",
@@ -0,0 +1,25 @@
import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { describe, expect, it } from "vitest";
import { createFileServer } from "./fileServer.js";
describe("createFileServer when the port is taken", () => {
it("rejects instead of never settling", async () => {
const projectDir = mkdtempSync(join(tmpdir(), "hf-file-server-taken-"));
try {
writeFileSync(join(projectDir, "index.html"), "<!DOCTYPE html><html><body></body></html>");
const options = { projectDir, preHeadScripts: [], headScripts: [] };
const first = await createFileServer(options);
try {
await expect(createFileServer({ ...options, port: first.port })).rejects.toThrow(
/EADDRINUSE/,
);
} finally {
first.close();
}
} finally {
rmSync(projectDir, { recursive: true, force: true });
}
});
});
+2 -1
View File
@@ -914,7 +914,7 @@ export function createFileServer(options: FileServerOptions): Promise<FileServer
}
});
return new Promise((resolve) => {
return new Promise((resolve, reject) => {
// Track open connections so we can force-destroy them on close.
// Without this, server.close() waits for keep-alive connections to
// drain, holding the Node.js event loop open indefinitely.
@@ -947,6 +947,7 @@ export function createFileServer(options: FileServerOptions): Promise<FileServer
connections.add(socket);
socket.on("close", () => connections.delete(socket));
});
server.on("error", reject);
});
}