Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(NODE-5409)!: allow socks to be installed optionally #3782

Merged
merged 1 commit into from
Jul 26, 2023

Conversation

nbbeeken
Copy link
Contributor

@nbbeeken nbbeeken commented Jul 21, 2023

Description

What is changing?

  • Add getSocks method to deps
  • update dependencies test for socks, and general imports
Is there new documentation needed for these changes?

No

What is the motivation for this change?

See highlight

Release Highlight

Allow socks to be installed optionally

The driver uses the socks dependency to connect to mongod or mongos through a SOCKS5 proxy. socks used to be a required dependency of the driver and was installed automatically. Now, socks is a peerDependency that must be installed to enable socks proxy support.

Double check the following

  • Ran npm run check:lint script
  • 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

@nbbeeken nbbeeken force-pushed the NODE-5409-socks-optional branch from b123d76 to 1c6fdcb Compare July 21, 2023 20:57
@nbbeeken nbbeeken marked this pull request as ready for review July 24, 2023 17:49
@baileympearson baileympearson self-assigned this Jul 25, 2023
@baileympearson baileympearson added the Primary Review In Review with primary reviewer, not yet ready for team's eyes label Jul 25, 2023

/** @type {import('../deps').SocksLib | null} */
let socks = null;
function loadSocks() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this necessary? makeModuleError returns a proxy that throws whenever a key that isn't kModuleError is accessed. So I'd expect we would just do the following (where it's used):

const socks = loadSocks();
await socks.SocksClient(...)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm alinging with the approach taken for kerberos, zstd, snappy. The goal is to not invoke the import operation more than once, determined by the nullishness of the socks variable.

let socks: SocksLib | null = null;
function loadSocks() {
if (socks == null) {
const socksImport = getSocks();
Copy link
Contributor

Choose a reason for hiding this comment

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

same comment as in stateMachine.js.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ditto response

Copy link
Contributor

@baileympearson baileympearson left a comment

Choose a reason for hiding this comment

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

questions about how we're importing socks

@nbbeeken nbbeeken force-pushed the NODE-5409-socks-optional branch from 410510a to ac1316e Compare July 25, 2023 20:08
@nbbeeken nbbeeken requested a review from baileympearson July 26, 2023 16:49
@baileympearson baileympearson merged commit 787bdbf into main Jul 26, 2023
@baileympearson baileympearson deleted the NODE-5409-socks-optional branch July 26, 2023 17:32
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.

2 participants