Skip to content

Build your personal knowledge base with Trilium Notes

fix(server): stop logging no-op ping broadcasts

Elian Doran8e4398f797f6
diff --git a/packages/trilium-core/src/services/messaging/index.spec.ts b/packages/trilium-core/src/services/messaging/index.spec.ts
index ce9dd72928..1c7dd5a083 100644
--- a/packages/trilium-core/src/services/messaging/index.spec.ts
+++ b/packages/trilium-core/src/services/messaging/index.spec.ts
@@ -50,10 +50,10 @@ describe("messaging provider (core)", () => {
it("excludes frequent/noisy message types from broadcast logging", () => {
expect(shouldLogMessage({ type: "frontend-update" } as WebSocketMessage)).toBe(false);
+ expect(shouldLogMessage({ type: "ping" } as WebSocketMessage)).toBe(false);
expect(shouldLogMessage({ type: "sync-failed" } as WebSocketMessage)).toBe(false);
expect(shouldLogMessage({ type: "api-log-messages" } as WebSocketMessage)).toBe(false);
- expect(shouldLogMessage({ type: "ping" } as WebSocketMessage)).toBe(true);
expect(shouldLogMessage({ type: "sync-finished" } as WebSocketMessage)).toBe(true);
expect(shouldLogMessage({ type: "reload-frontend" } as WebSocketMessage)).toBe(true);
});
diff --git a/packages/trilium-core/src/services/messaging/index.ts b/packages/trilium-core/src/services/messaging/index.ts
index a1feb20d68..c0a18ea4e4 100644
--- a/packages/trilium-core/src/services/messaging/index.ts
+++ b/packages/trilium-core/src/services/messaging/index.ts
@@ -44,11 +44,12 @@ export function sendMessageToAllClients(message: WebSocketMessage): void {
/**
* Message types excluded from broadcast logging: "frontend-update" fires on
- * every write transaction and embeds full entity payloads, "api-log-messages"
- * would recursively log API log output, and "sync-failed" repeats on every
- * failed sync attempt.
+ * every write transaction and embeds full entity payloads, "ping" fires on
+ * every no-change transaction and carries no data, "api-log-messages" would
+ * recursively log API log output, and "sync-failed" repeats on every failed
+ * sync attempt.
*/
-const UNLOGGED_MESSAGE_TYPES = new Set<WebSocketMessage["type"]>(["frontend-update", "sync-failed", "api-log-messages"]);
+const UNLOGGED_MESSAGE_TYPES = new Set<WebSocketMessage["type"]>(["frontend-update", "ping", "sync-failed", "api-log-messages"]);
/**
* Whether a broadcast message should be logged by the messaging provider,