-
Notifications
You must be signed in to change notification settings - Fork 1.8k
feat(NODE-7009): add client metadata on demand #4574
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
base: main
Are you sure you want to change the base?
Conversation
@@ -1037,8 +1075,8 @@ export interface MongoOptions | |||
dbName: string; | |||
/** @deprecated - Will be made internal in a future major release. */ | |||
metadata: ClientMetadata; | |||
/** @internal */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This put Claude in an infinite loop. We omit/pick some of our readonly client options in order to modify them while the rest remain immutable. This means they cannot be internal if we want to modify them in this fashion, and now the metadata on the client with this feature is no longer immutable.
@@ -119,6 +122,18 @@ export function makeClientMetadata(options: MakeClientMetadataOptions): ClientMe | |||
version: version.length > 0 ? `${NODE_DRIVER_VERSION}|${version}` : NODE_DRIVER_VERSION | |||
}; | |||
|
|||
// This is where we handle additional driver info added after client construction. | |||
if (options.additionalDriverInfo?.length > 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if additionalDriverInfo is always defaulted to []
, what could cause it to become unset?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Our test suite doesn't have the same strict type restrictions and can be directly unset there. I considered that out of scope and to defensively program here.
Description
Allows appending driver info for the client metadata after a mongo client has been constructed.
What is changing?
appendMetadata
toMongoClient
Is there new documentation needed for these changes?
Manual docs.
What is the motivation for this change?
NODE-7009
Release Highlight
Clients now can add handshake metadata post construction
Driver information such as name, version, and platform are allowed:
Double check the following
npm run check:lint
scripttype(NODE-xxxx)[!]: description
feat(NODE-1234)!: rewriting everything in coffeescript