Skip to content

armgit / kaneo

Public Imported from GitHub
0

⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.

fix: address verified concurrency and migration review findings

Tin09e1b4187d18
diff --git a/apps/api/src/ws/index.ts b/apps/api/src/ws/index.ts
index cb312f280..d99649056 100644
--- a/apps/api/src/ws/index.ts
+++ b/apps/api/src/ws/index.ts
@@ -290,7 +290,7 @@ async function deliverToLocalConnections(
workspaceId = await currentProjectWorkspace(projectId);
} catch (error) {
console.error("Failed to validate project broadcast access:", error);
- workspaceId = null;
+ return;
}
let members = new Set<string>();
if (workspaceId) {
@@ -324,6 +324,7 @@ async function deliverToLocalConnections(
}
} catch (error) {
console.error("Failed to validate broadcast membership:", error);
+ return;
}
}
const payload = JSON.stringify(message);
diff --git a/tests/api/ws/project-move.test.ts b/tests/api/ws/project-move.test.ts
index b1209feb9..a33fa8f29 100644
--- a/tests/api/ws/project-move.test.ts
+++ b/tests/api/ws/project-move.test.ts
@@ -113,16 +113,24 @@ describe("project move revocation", () => {
expect(old.close).toHaveBeenCalled();
expect(current.send).toHaveBeenCalledWith(JSON.stringify(update));
});
- it("fails closed when workspace lookup fails", async () => {
- vi.useFakeTimers();
- await initializeWebSocketAdapter();
- const old = connect();
- m.lookup.mockRejectedValueOnce(new Error("Database unavailable"));
- broadcastToProject("project", update);
- await vi.advanceTimersByTimeAsync(100);
- expect(old.send).not.toHaveBeenCalled();
- expect(old.close).toHaveBeenCalled();
- });
+ it.each(["workspace", "membership"])(
+ "skips delivery without revoking access on transient %s lookup failure",
+ async (lookup) => {
+ vi.useFakeTimers();
+ await initializeWebSocketAdapter();
+ const old = connect();
+ (lookup === "workspace" ? m.lookup : m.members).mockRejectedValueOnce(
+ new Error("Database unavailable"),
+ );
+ broadcastToProject("project", update);
+ await vi.advanceTimersByTimeAsync(100);
+ expect(old.send).not.toHaveBeenCalled();
+ expect(old.close).not.toHaveBeenCalled();
+ broadcastToProject("project", update);
+ await vi.advanceTimersByTimeAsync(100);
+ expect(old.send).toHaveBeenCalledWith(JSON.stringify(update));
+ },
+ );
it("does not send an in-flight update after local revocation", async () => {
vi.useFakeTimers();
await initializeWebSocketAdapter();