Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

fix(robinhood-feed): drop SSE and WS subscribers on shutdown so close returns

nirholasf95e648f1fc9
diff --git a/workers/robinhood-feed/src/server.js b/workers/robinhood-feed/src/server.js
index c681d9e91..a72b889e9 100644
--- a/workers/robinhood-feed/src/server.js
+++ b/workers/robinhood-feed/src/server.js
@@ -117,7 +117,22 @@ export function createServer(firehose) {
}
});
- return { server, onEvent, recent };
+ /**
+ * Shut the server down for real. SSE responses and WebSockets are long-lived
+ * by design, so a bare `server.close()` waits for subscribers that will never
+ * hang up — on Cloud Run that turns a revision rollover into a SIGKILL after
+ * the grace period. Drop the subscribers first, then close.
+ */
+ async function close() {
+ for (const c of sseClients) { try { c.res.end(); } catch { /* already gone */ } }
+ sseClients.clear();
+ for (const ws of wss.clients) { try { ws.terminate(); } catch { /* already gone */ } }
+ await new Promise((resolve) => { wss.close(() => resolve()); });
+ server.closeAllConnections();
+ await new Promise((resolve) => { server.close(() => resolve()); });
+ }
+
+ return { server, onEvent, recent, close };
}
function json(res, code, body) {