Skip to content

Commit 0c3ac1f

Browse files
ggazzosampaiodiego
andauthored
chore: deprecates dbWatchers and set default value to false (#35981)
Co-authored-by: Diego Sampaio <[email protected]>
1 parent 3b0ef43 commit 0c3ac1f

File tree

4 files changed

+22
-8
lines changed

4 files changed

+22
-8
lines changed

.changeset/cuddly-feet-clap.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
"@rocket.chat/meteor": patch
3+
"@rocket.chat/models": patch
4+
---
5+
6+
Deprecates the use of MongoDB oplog or Change Streams to receive real time data updates.
7+
8+
The previous behavior can still be enabled using the environment flag `DISABLE_DB_WATCHERS=false`.
9+
10+
⚠️ In future major versions, this flag will be completely removed, and the `@rocket.chat/stream-hub-service` package and the `stream-hub-service` Docker image will no longer be published.

.github/workflows/ci-test-e2e.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ jobs:
8686
mongodb-version: ${{ fromJSON(inputs.mongodb-version) }}
8787
shard: ${{ fromJSON(inputs.shard) }}
8888

89-
name: MongoDB ${{ matrix.mongodb-version }}${{ inputs.db-watcher-disabled == 'true' && ' [no watchers]' || '' }} (${{ matrix.shard }}/${{ inputs.total-shard }}) - ${{ (matrix.mongodb-version == '7.0' && 'Debian' && false) || 'Alpine (Official)' }}
89+
name: MongoDB ${{ matrix.mongodb-version }}${{ inputs.db-watcher-disabled == 'false' && ' [legacy watchers]' || '' }} (${{ matrix.shard }}/${{ inputs.total-shard }}) - ${{ (matrix.mongodb-version == '7.0' && 'Debian' && false) || 'Alpine (Official)' }}
9090

9191
steps:
9292
- name: Collect Workflow Telemetry

.github/workflows/ci.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@ jobs:
531531
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
532532
REPORTER_JIRA_ROCKETCHAT_API_KEY: ${{ secrets.REPORTER_JIRA_ROCKETCHAT_API_KEY }}
533533

534-
test-ui-ee-no-watcher:
534+
test-ui-ee-watcher:
535535
name: 🔨 Test UI (EE)
536536
needs: [checks, build-gh-docker-coverage, release-versions]
537537

@@ -551,7 +551,7 @@ jobs:
551551
rc-docker-tag: ${{ needs.release-versions.outputs.rc-docker-tag }}
552552
gh-docker-tag: ${{ needs.release-versions.outputs.gh-docker-tag }}
553553
retries: ${{ (github.event_name == 'release' || github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/master') && 2 || 0 }}
554-
db-watcher-disabled: 'true'
554+
db-watcher-disabled: 'false'
555555
secrets:
556556
CR_USER: ${{ secrets.CR_USER }}
557557
CR_PAT: ${{ secrets.CR_PAT }}
@@ -564,7 +564,7 @@ jobs:
564564
tests-done:
565565
name: ✅ Tests Done
566566
runs-on: ubuntu-24.04
567-
needs: [checks, test-unit, test-api, test-ui, test-api-ee, test-ui-ee, test-ui-ee-no-watcher]
567+
needs: [checks, test-unit, test-api, test-ui, test-api-ee, test-ui-ee, test-ui-ee-watcher]
568568
if: always()
569569
steps:
570570
- name: Test finish aggregation
@@ -593,7 +593,7 @@ jobs:
593593
exit 1
594594
fi
595595
596-
if [[ '${{ needs.test-ui-ee-no-watcher.result }}' != 'success' ]]; then
596+
if [[ '${{ needs.test-ui-ee-watcher.result }}' != 'success' ]]; then
597597
exit 1
598598
fi
599599

packages/models/src/index.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,7 @@ export function getCollectionName(name: string): string {
125125

126126
const disabledEnvVar = String(process.env.DISABLE_DB_WATCHERS).toLowerCase();
127127

128-
export const dbWatchersDisabled =
129-
(process.env.NODE_ENV === 'production' && ['yes', 'true'].includes(disabledEnvVar)) ||
130-
(process.env.NODE_ENV !== 'production' && !['no', 'false'].includes(disabledEnvVar));
128+
export const dbWatchersDisabled = !['no', 'false'].includes(disabledEnvVar);
131129

132130
export * from './modelClasses';
133131
export * from './DatabaseWatcher';
@@ -257,3 +255,9 @@ export function registerServiceModels(db: Db, trash?: Collection<RocketChatRecor
257255
registerModel('IUploadsModel', () => new UploadsRaw(db));
258256
registerModel('ILivechatVisitorsModel', () => new LivechatVisitorsRaw(db));
259257
}
258+
259+
if (!dbWatchersDisabled) {
260+
console.warn(
261+
`Database watchers is enabled and this is not the default option.\nRocket.Chat deprecated the usage of \`oplog/change streams\` and are going to remove it the next major version (8.0.0).`,
262+
);
263+
}

0 commit comments

Comments
 (0)