Skip to content

fix(data-service): remove compass connectivity check via ping COMPASS-9455#7897

Open
nbbeeken wants to merge 3 commits intomainfrom
COMPASS-9455
Open

fix(data-service): remove compass connectivity check via ping COMPASS-9455#7897
nbbeeken wants to merge 3 commits intomainfrom
COMPASS-9455

Conversation

@nbbeeken
Copy link
Copy Markdown
Collaborator

Description

We now use a driver version that does connection checkout/in verifying connectivity and auth in the connect method!! -1 RTT. huge!

Checklist

  • New tests and/or benchmarks are included
  • Documentation is changed or added
  • If this change updates the UI, screenshots/videos are added and a design review is requested
  • If this change could impact the load on the MongoDB cluster, please describe the expected and worst case impact
  • I have signed the MongoDB Contributor License Agreement (https://www.mongodb.com/legal/contributor-agreement)

Motivation and Context

  • Bugfix
  • New feature
  • Dependency update
  • Misc

Open Questions

Dependents

Types of changes

  • Backport Needed
  • Patch (non-breaking change which fixes an issue)
  • Minor (non-breaking change which adds functionality)
  • Major (fix or feature that would cause existing functionality to change)

@nbbeeken nbbeeken requested a review from a team as a code owner March 23, 2026 21:19
@nbbeeken nbbeeken requested review from Copilot and lerouxb and removed request for Copilot March 23, 2026 21:19
@github-actions github-actions bot added the fix label Mar 23, 2026
Copilot AI review requested due to automatic review settings March 23, 2026 21:34
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Removes the explicit post-connect ping round-trip in data-service so connections rely on the driver’s connect() verification, reducing one RTT during connection establishment.

Changes:

  • Removed the runCommand(..., { ping: 1 }) connectivity check after creating a client.
  • Updated the test suite by removing the ping/readPreference-specific assertion and associated type import cleanup.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
packages/data-service/src/connect-mongo-client.ts Drops the explicit ping command executed right after connectMongoClient() completes.
packages/data-service/src/connect-mongo-client.spec.ts Removes a ping-specific test and cleans up now-unused MongoDB event typing.

Comment on lines 183 to 185

it('should not run the ping command with the specified ReadPreference', async function () {
const connectionString = clusterConnectionStringURL.clone();
connectionString
.typedSearchParams<MongoClientOptions>()
.set('readPreference', 'secondaryPreferred');
const commands: CommandStartedEvent[] = [];
const [metadataClient, crudClient, , state] = await connectMongoClient({
connectionOptions: {
connectionString: connectionString.toString(),
},
setupListeners: (client) =>
client.on('commandStarted', (ev) => commands.push(ev)),
});
expect(commands).to.have.lengthOf(1);
expect(commands[0].commandName).to.equal('ping');
expect(commands[0].command.$readPreference).to.equal(undefined);

for (const closeLater of [metadataClient, crudClient, state]) {
toBeClosed.add(closeLater);
}
});

describe('ssh tunnel failures', function () {
// Use async_hooks to track the state of the internal network server used
Copy link

Copilot AI Mar 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR removes the ping-on-connect behavior but also removes the only test that asserted a ping command was issued. To prevent regressions (reintroducing the extra RTT), consider replacing it with a test that asserts no ping command is emitted during connectMongoClient (e.g., via commandStarted events and checking that none have commandName === 'ping').

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Collaborator

@gribnoysup gribnoysup left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a bad suggestion to add a new test for this, otherwise lgtm

@nbbeeken
Copy link
Copy Markdown
Collaborator Author

Depends on: mongodb-js/devtools-shared#628

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants