Visitar URL original
fix(NODE-7881): hello command is compressed by PavelSafronov · Pull Request #5072 · mongodb/node-mongodb-native · GitHub
Skip to content

fix(NODE-7881): hello command is compressed - #5072

Open
PavelSafronov wants to merge 2 commits into
mainfrom
PavelSafronov/node-7881
Open

PavelSafronov wants to merge 2 commits into
mainfrom
PavelSafronov/node-7881

Conversation

@PavelSafronov

Copy link
Copy Markdown
Contributor

Description

Summary of Changes

Never compress hello commands.

Release Highlight

Double check the following

  • Lint is passing (npm run check:lint)
  • Self-review completed using the steps outlined here
  • PR title follows the correct format: type(NODE-xxxx)[!]: description
    • Example: feat(NODE-1234)!: rewriting everything in coffeescript
  • Changes are covered by tests
  • New TODOs have a related JIRA ticket

@PavelSafronov
PavelSafronov marked this pull request as ready for review October 6, 2026 23:07
@PavelSafronov
PavelSafronov requested a review from a team as a code owner October 6, 2026 23:07
Copilot AI balanced review requested due to automatic review settings October 6, 2026 23:07

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

The implementation matches the compression specification and includes focused unit and integration coverage.

Review effort: Balanced
Findings: None

What changed in this PR

Prevents all modern and legacy hello commands from using wire compression.

Changes:

  • Adds hello variants to the non-compressible command set.
  • Expands unit and SFP coverage for monitoring commands.
  • Adds an integration-test hook detecting prohibited compression.
File Description
src/​cmap/​wire_protocol/​compression.ts Excludes modern and legacy hello commands from compression.
test/​unit/​commands.test.ts Tests prohibited commands across both wire protocols.
test/​unit/​sdam/​monitor.test.ts Verifies polling, streaming, and RTT hellos remain uncompressed.
test/​tools/​runner/​hooks/​compression_checker.ts Detects forbidden compressed commands during integration tests.
test/​mocha_mongodb.js Registers the compression checker.
test/​manual/​sfp.test.ts Validates compressed SFP configurations maintain healthy monitoring.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread test/manual/sfp.test.ts

/**
* Monitoring connections are never authenticated, and the SFP rejects compressed messages on
* unauthenticated connections. If the driver compresses a monitoring `hello`, the SFP closes the

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Let's not mention SFP behavior here, as it's likely to change independent of the driver.

Comment thread test/unit/commands.test.ts
Comment thread test/unit/sdam/monitor.test.ts

// The handshake is never compressed because the compressor is only agreed upon in its
// reply, so these tests only inspect the hello commands sent after the handshake.
const isPostHandshakeHello = doc => isHello(doc) && !('compression' in doc);

@tadjik1 tadjik1 Oct 7, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is it going to be true for all "non-compression" variants? I also not really follow, why do we want to focus on PostHandshakeHello commands here, can you elaborate please?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Is it going to be true for all "non-compression" variants?

Yes, this will be true for all non-compression variants, since we explicitly pass compressors: ['zlib'] to the Monitor.

I also not really follow, why do we want to focus on PostHandshakeHello commands here, can you elaborate please?

We're only focusing on the post-handshake hellos because that's what's currently broken: we don't compress the handshake hello, but do compress the others.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

we don't compress the handshake hello

Is it because handshake goes through different code branch? The current solution looks good but a bit difficult to follow (I assume because we deal with low-level OP_COMPRESSED), I'm wondering if we might have simpler way to test monitoring.

For example, couple of lines below the comment says "leave the awaitable hello pending" and then call resolveAwaitableHello(doc);, it's unclear how these 2 are not contradicting each other. I saw that unit tests before were using public interface of the OpCompressedRequest, could this, for example, be enough for our use-case?

@tadjik1 tadjik1 self-assigned this Oct 8, 2026
@tadjik1 tadjik1 added the Primary Review In Review with primary reviewer, not yet ready for team's eyes label Oct 8, 2026

This branch has not been deployed

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

Labels

Primary Review In Review with primary reviewer, not yet ready for team's eyes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants