The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
fix(debug): bound core RPC requests with a timeout
Steven Enamakel36ec89c02713
diff --git a/scripts/__tests__/debug-web-ui.test.mjs b/scripts/__tests__/debug-web-ui.test.mjsindex bb89d73744..baa74c58f7 100644--- a/scripts/__tests__/debug-web-ui.test.mjs+++ b/scripts/__tests__/debug-web-ui.test.mjs@@ -4,6 +4,7 @@ import test from "node:test";import {coreLaunchSpec,+ createCoreRpcClient,devConnectUrl,ensureSignedInChat,mergeChildEnv,@@ -83,6 +84,25 @@ test("ensureSignedInChat propagates its bounded composer wait failure", async ()assert.equal(navigatedTo, "http://localhost:1420/#/chat");});+test("core RPC client bounds a stalled request and propagates its timeout", async () => {+ 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:7788/rpc",+ "test-token",+ hangingFetch,+ 5,+ );++ await assert.rejects(rpc("openhuman.auth_get_state"), { name: "TimeoutError" });+ assert.equal(signal.aborted, true);+});+test("coreLaunchSpec isolates the core from operator credentials, storage, and dotenv", () => {const inheritedEnv = {OPENHUMAN_BACKEND_API_KEY: "inherited",diff --git a/scripts/debug/web-ui-lib.mjs b/scripts/debug/web-ui-lib.mjsindex ebfae4209c..1871f0a284 100644--- a/scripts/debug/web-ui-lib.mjs+++ b/scripts/debug/web-ui-lib.mjs@@ -57,6 +57,24 @@ export async function ensureSignedInChat(page, appOrigin) {await composer.waitFor({ state: "visible", timeout: 120_000 });}+/** Create an authenticated core RPC client with a bounded request lifetime. */+export function createCoreRpcClient(rpcUrl, token, fetchImpl = fetch, timeoutMs = 10_000) {+ return async (method, params = {}) => {+ const res = await fetchImpl(rpcUrl, {+ method: "POST",+ headers: {+ "content-type": "application/json",+ authorization: `Bearer ${token}`,+ },+ body: JSON.stringify({ jsonrpc: "2.0", id: Date.now(), method, params }),+ signal: AbortSignal.timeout(timeoutMs),+ });+ const body = await res.json();+ if (body.error) throw new Error(`${method}: ${body.error.message}`);+ return body.result;+ };+}+export const USAGE = `Usage: pnpm debug web [options]Boots a throwaway stack — mock backend, a fresh \`openhuman-core serve\` on adiff --git a/scripts/debug/web-ui.mjs b/scripts/debug/web-ui.mjsindex 5a28dd36e1..a3029a49c3 100644--- a/scripts/debug/web-ui.mjs+++ b/scripts/debug/web-ui.mjs@@ -24,6 +24,7 @@ import {devConnectUrl,ensureSignedInChat,coreLaunchSpec,+ createCoreRpcClient,freePort,isLoopback,mergeChildEnv,@@ -269,19 +270,7 @@ async function main() {return file;};- const rpc = async (method, params = {}) => {- const res = await fetch(rpcUrl, {- method: "POST",- headers: {- "content-type": "application/json",- authorization: `Bearer ${token}`,- },- body: JSON.stringify({ jsonrpc: "2.0", id: Date.now(), method, params }),- });- const body = await res.json();- if (body.error) throw new Error(`${method}: ${body.error.message}`);- return body.result;- };+ const rpc = createCoreRpcClient(rpcUrl, token);// The first load compiles the app's modules on demand; give it room.page.setDefaultNavigationTimeout(120_000);