Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

test: replace stalled RPC server with injected hanging fetch

Steven Enamakel80afab0af082
diff --git a/scripts/__tests__/debug-web-ui.test.mjs b/scripts/__tests__/debug-web-ui.test.mjs
index dcc84b30bb..5471a83fc4 100644
--- a/scripts/__tests__/debug-web-ui.test.mjs
+++ b/scripts/__tests__/debug-web-ui.test.mjs
@@ -1,5 +1,4 @@
import assert from "node:assert/strict";
-import { createServer } from "node:http";
import net from "node:net";
import test from "node:test";
@@ -104,27 +103,32 @@ test("ensureSignedInChat propagates its bounded composer wait failure", async ()
});
test("core RPC client bounds a stalled request and propagates its timeout", async () => {
- const server = createServer(() => {});
- await new Promise((resolve, reject) => {
- server.once("error", reject);
- server.listen(0, "127.0.0.1", resolve);
- });
-
- const { port } = server.address();
+ let signal;
+ const hangingFetch = (_url, init) => {
+ signal = init.signal;
+ return new Promise((_resolve, reject) => {
+ signal.addEventListener("abort", () => reject(signal.reason), {
+ once: true,
+ });
+ });
+ };
const rpc = createCoreRpcClient(
- `http://127.0.0.1:${port}/rpc`,
+ "http://127.0.0.1:7788/rpc",
"test-token",
- fetch,
+ hangingFetch,
5,
);
+ // AbortSignal.timeout uses an unref'd timer. Keep the test process alive so
+ // the simulated stalled fetch can observe that timer without real network I/O.
+ const keepAlive = setInterval(() => {}, 1_000);
try {
await assert.rejects(rpc("openhuman.auth_get_state"), {
name: "TimeoutError",
});
} finally {
- server.closeAllConnections();
- await new Promise((resolve) => server.close(resolve));
+ clearInterval(keepAlive);
}
+ assert.equal(signal.aborted, true);
});
test("coreLaunchSpec isolates the core from operator credentials, storage, and dotenv", () => {
diff --git a/scripts/i18n-coverage.ts b/scripts/i18n-coverage.ts
index 0b52929216..0fc1a8525e 100644
--- a/scripts/i18n-coverage.ts
+++ b/scripts/i18n-coverage.ts
@@ -180,15 +180,18 @@ async function collectUsedKeys(): Promise<Set<string>> {
}
// The core supplies these keys on chat_error events; the UI translates
// event.copy_key rather than spelling each key in a literal t() call.
- const failureCopy = await fs.readFile(
- path.join(
- ROOT,
- "crates/openhuman-core/src/inference/failure_copy/table.rs",
- ),
- "utf8",
- );
- for (const match of failureCopy.matchAll(/"(chat_error\.[a-z_]+)"/g)) {
- used.add(match[1]);
+ // Generic inference failures are owned by TinyInference; OpenHuman's table
+ // adds product-specific overrides. Both sets are emitted through the same
+ // chat_error event and translated by the UI's dynamic copy_key lookup.
+ const failureCopySources = [
+ "crates/openhuman-core/src/inference/failure_copy/table.rs",
+ "vendor/tinyagents/vendor/tinyinference/crates/tinyinference-llm/src/failure/copy.rs",
+ ];
+ for (const source of failureCopySources) {
+ const failureCopy = await fs.readFile(path.join(ROOT, source), "utf8");
+ for (const match of failureCopy.matchAll(/"(chat_error\.[a-z_]+)"/g)) {
+ used.add(match[1]);
+ }
}
return used;
}