mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-23 11:29:54 +00:00
* test(studio-server): a preview file request on a silent drive asks it nothing on the event loop * fix(studio-server): a preview file request reads its project off the event loop * ci(studio-server): refuse a new synchronous fs call in Studio's routes and history engine * fix(studio-server): a preview file request and a miss stay off the event loop to the end * test(studio-server): a shared still's remake no longer depends on busy requests' slot order * fix(ci): the studio-server sync fs gate counts every sync call node:fs has, globSync included
33 lines
1.5 KiB
JavaScript
33 lines
1.5 KiB
JavaScript
import { test } from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import * as fs from "node:fs";
|
|
import { countSyncCalls, gained } from "./check-studio-server-sync-fs.mjs";
|
|
|
|
test("counts synchronous fs calls a file makes, not the ones a comment names", () => {
|
|
const source = [
|
|
"const stat = existsSync(file) ? statSync(file) : null;",
|
|
"// readFileSync(file) would hold the event loop",
|
|
"const text = await readFile(file);",
|
|
"const names = readdirSync (dir);",
|
|
"const real = realpathSync.native(dir);",
|
|
"readSync(fd, buffer); writeSync(fd, buffer); fstatSync(fd);",
|
|
].join("\n");
|
|
assert.equal(countSyncCalls(source), 7);
|
|
});
|
|
|
|
test("a file may lose synchronous fs calls, never gain one, and a new file starts at none", () => {
|
|
const baseline = { "routes/preview.ts": 4 };
|
|
assert.deepEqual(gained({ "routes/preview.ts": 3 }, baseline), []);
|
|
assert.deepEqual(gained({ "routes/preview.ts": 5, "routes/new.ts": 1 }, baseline), [
|
|
"routes/preview.ts: 5 synchronous fs calls, 4 allowed",
|
|
"routes/new.ts: 1 synchronous fs calls, 0 allowed",
|
|
]);
|
|
});
|
|
|
|
// fails without the fix: the gate kept its own list of names, so a new route calling Node 22's globSync passed.
|
|
test("every synchronous call node:fs has is counted, globSync included", () => {
|
|
const names = Object.keys(fs).filter((name) => name.endsWith("Sync"));
|
|
assert.ok(names.includes("globSync"), "this Node has globSync");
|
|
for (const name of names) assert.equal(countSyncCalls(`${name}(x);`), 1, name);
|
|
});
|