Skip to content

armgit / AiSOC

Public Imported from GitHub
0

Open-source AI Security Operations Center: alert fusion, LLM-agent triage, MITRE ATT&CK investigation, and a replayable decision ledger for every agent step. Self-hostable, runs with no API keys, MIT licensed. Ships an MCP server for Claude, Cursor and Continue.

fix(web): give the console's service proxy more than 30 s (#1270)

antigravitysoham-engfa1679877607
diff --git a/apps/web/next.config.js b/apps/web/next.config.js
index 0e8e89d1e..39f17d1c5 100644
--- a/apps/web/next.config.js
+++ b/apps/web/next.config.js
@@ -51,6 +51,15 @@ const PURPLE_TEAM_HOST = process.env.PURPLE_TEAM_URL || 'http://localhost:8006';
const nextConfig = {
reactStrictMode: true,
+ // The rewrites below proxy the console to agents, fusion and the rest, and
+ // Next's proxy gives up after 30 s by default. Copilot's own model budget
+ // is also 30 s (safe_chat_completions_request), after which it answers
+ // with a labelled template, so on a slow model the proxy always cut the
+ // connection first: "socket hang up" and a bare 500 instead of the honest
+ // fallback. Long agent calls (investigations, hunts) hit the same wall.
+ experimental: {
+ proxyTimeout: Number(process.env.AISOC_PROXY_TIMEOUT_MS) || 120_000,
+ },
transpilePackages: ['@aisoc/ui', '@aisoc/types', '@aisoc/report-card'],
// pnpm monorepo: anchor Turbopack at the repository root so it can resolve
// the hoisted `next` package via apps/web/node_modules/next (symlink into
diff --git a/apps/web/src/lib/nextProxyTimeout.test.ts b/apps/web/src/lib/nextProxyTimeout.test.ts
new file mode 100644
index 000000000..89483fac8
--- /dev/null
+++ b/apps/web/src/lib/nextProxyTimeout.test.ts
@@ -0,0 +1,38 @@
+/**
+ * The console reaches the agents service through Next rewrites, whose proxy
+ * times out at 30 s unless `experimental.proxyTimeout` is set. Copilot's model
+ * call has a 30 s budget of its own and falls back to a labelled template
+ * after it, so with the default the proxy always dropped the connection
+ * first ("Failed to proxy http://agents:8084/api/v1/copilot/chat: socket hang
+ * up") and the analyst saw a 500 instead of the fallback.
+ */
+import { createRequire } from 'node:module';
+import path from 'node:path';
+import { describe, expect, it } from 'vitest';
+
+const require = createRequire(import.meta.url);
+const COPILOT_MODEL_BUDGET_MS = 30_000;
+
+function loadConfig(): { experimental?: { proxyTimeout?: number } } {
+ const file = path.join(process.cwd(), 'next.config.js');
+ delete require.cache[file];
+ return require(file);
+}
+
+describe('next.config proxy timeout', () => {
+ it('outlasts the Copilot model budget with room for the fallback reply', () => {
+ const timeout = loadConfig().experimental?.proxyTimeout ?? 30_000;
+ expect(timeout).toBeGreaterThanOrEqual(COPILOT_MODEL_BUDGET_MS * 2);
+ });
+
+ it('can be raised for slower deployments', () => {
+ const before = process.env.AISOC_PROXY_TIMEOUT_MS;
+ process.env.AISOC_PROXY_TIMEOUT_MS = '300000';
+ try {
+ expect(loadConfig().experimental?.proxyTimeout).toBe(300_000);
+ } finally {
+ if (before === undefined) delete process.env.AISOC_PROXY_TIMEOUT_MS;
+ else process.env.AISOC_PROXY_TIMEOUT_MS = before;
+ }
+ });
+});