fix(dashboard): return 404 for event streams of unknown projects

An SSE subscription with a nonexistent projectId (stale client tab, e2e fixture
page using projectId "fixture") surfaced the PG startup-factory construction
chain as a 500 on every poll, filling operator logs with alarming
"failed to construct TaskStore" errors. Map project-not-found to a clean 404,
matching the project routes' existing handling.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
gsxdsm
2026-08-15 22:42:51 -07:00
parent 87e673baf7
commit fad45c2d1f
2 changed files with 21 additions and 1 deletions

View File

@@ -0,0 +1,7 @@
---
"@runfusion/fusion": patch
---
summary: Dashboard event streams for an unknown project now return 404 instead of logging a 500 server error.
category: fix
dev: `/api/events` maps project-not-found store-resolution failures to 404 with a clean message; stale client tabs and e2e fixture pages no longer fill operator logs with startup-factory construction errors.

View File

@@ -1285,7 +1285,20 @@ export function createServer(store: TaskStore, options?: ServerOptions): ReturnT
automationStore,
)(req, res);
} catch (err: unknown) {
sendErrorResponse(res, 500, err instanceof Error ? err.message : "Failed to open project event stream");
/*
FNXC:ProjectScoping 2026-08-16-05:28:
An SSE subscription for a nonexistent project (e.g. a stale client tab or an
e2e fixture page using projectId "fixture") is a client addressing error, not a
server fault. Surfacing the startup-factory construction chain as a 500 filled
operator logs with alarming "failed to construct TaskStore" errors on every
poll; map project-not-found to 404 with a clean message instead.
*/
const message = err instanceof Error ? err.message : "Failed to open project event stream";
if (/Project (?:"[^"]*" )?not found/.test(message)) {
sendErrorResponse(res, 404, `Project "${projectId}" not found`);
return;
}
sendErrorResponse(res, 500, message);
}
});