From 06c84f0bf5d7cd9a06cbbfe2e96e6341f508ac8d Mon Sep 17 00:00:00 2001 From: Brendan Kellam Date: Tue, 11 Nov 2025 20:31:08 -0800 Subject: [PATCH] fix(worker): Fix issue where connections would always sync on startup (#613) --- CHANGELOG.md | 1 + packages/backend/package.json | 1 + packages/backend/src/configManager.ts | 5 +++-- yarn.lock | 1 + 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 37ce8d24..fce2fdf5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fixed incorrect shutdown of PostHog SDK in the worker. [#609](https://github.com/sourcebot-dev/sourcebot/pull/609) - Fixed race condition in job schedulers. [#607](https://github.com/sourcebot-dev/sourcebot/pull/607) - Fixed connection sync jobs getting stuck in pending or in progress after restarting the worker. [#612](https://github.com/sourcebot-dev/sourcebot/pull/612) +- Fixed issue where connections would always sync on startup, regardless if they changed or not. [#613](https://github.com/sourcebot-dev/sourcebot/pull/613) ### Added - Added force resync buttons for connections and repositories. [#610](https://github.com/sourcebot-dev/sourcebot/pull/610) diff --git a/packages/backend/package.json b/packages/backend/package.json index 201bd886..a8ffb315 100644 --- a/packages/backend/package.json +++ b/packages/backend/package.json @@ -41,6 +41,7 @@ "dotenv": "^16.4.5", "express": "^4.21.2", "express-async-errors": "^3.1.1", + "fast-deep-equal": "^3.1.3", "git-url-parse": "^16.1.0", "gitea-js": "^1.22.0", "glob": "^11.0.0", diff --git a/packages/backend/src/configManager.ts b/packages/backend/src/configManager.ts index 6049a52f..fed01863 100644 --- a/packages/backend/src/configManager.ts +++ b/packages/backend/src/configManager.ts @@ -6,6 +6,7 @@ import chokidar, { FSWatcher } from 'chokidar'; import { ConnectionManager } from "./connectionManager.js"; import { SINGLE_TENANT_ORG_ID } from "./constants.js"; import { syncSearchContexts } from "./ee/syncSearchContexts.js"; +import isEqual from 'fast-deep-equal'; const logger = createLogger('config-manager'); @@ -64,8 +65,8 @@ export class ConfigManager { const existingConnectionConfig = existingConnection ? existingConnection.config as unknown as ConnectionConfig : undefined; const connectionNeedsSyncing = - !existingConnection || - (JSON.stringify(existingConnectionConfig) !== JSON.stringify(newConnectionConfig)); + !existingConnectionConfig || + !isEqual(existingConnectionConfig, newConnectionConfig); // Either update the existing connection or create a new one. const connection = existingConnection ? diff --git a/yarn.lock b/yarn.lock index e47ad883..f103fe78 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7909,6 +7909,7 @@ __metadata: dotenv: "npm:^16.4.5" express: "npm:^4.21.2" express-async-errors: "npm:^3.1.1" + fast-deep-equal: "npm:^3.1.3" git-url-parse: "npm:^16.1.0" gitea-js: "npm:^1.22.0" glob: "npm:^11.0.0"