-
Notifications
You must be signed in to change notification settings - Fork 1.8k
refactor(NODE-5136): make authentication use async / await #3607
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
Conversation
550ea60
to
9138094
Compare
spn = `${spn}@${mechanismProperties.SERVICE_REALM}`; | ||
} | ||
|
||
return initializeClient(spn, initOptions); |
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.
what does initialize client return? you've removed the logic that checks for a null
client after calling makeKerberosClient
, which is only safe to do if initializeClient
never resolves to null.
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.
The null checks are all to make typescript happy, TS did not handle the mutual exclusion of the two arguments passed to the callback. this function will throw if it doesn't return a client
@@ -61,7 +60,16 @@ export function connect(options: ConnectionOptions, callback: Callback<Connectio | |||
if (options.autoEncrypter) { |
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.
Just because we've come this far, do you want to refactor up one more function?
const makeConnectionAsync = promisify(makeConnection);
async function connectAsync(..) {
}
export const connect = callbackify(connectAsync);
I don't think it makes sense to make makeConnection
async, because ideally we'll refactor it eventually so it's not performing io at all (purely synchronous). It also currently handles event listeners on the socket, so just wrapping it in a promisify seems more straightforward.
With this last refactor, the auth module is basically completely refactored.
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.
I looked into making this change but it would only be usable here, the socks5 logic would need to be untangled from callbacks as well. Or we leave socks5 unchanged and it still uses the callback form at which point we haven't got much value out of making a promisified version. Let's stick with what we got so far
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.
verbal approval because Github won't let me approve my own PR
Description
What is changing?
This PR cherry-picks unrelated refactors out of https://jira.mongodb.org/browse/NODE-3998. This is done to simplify review, as well as limit the surface area that I need to debug while looking for the issues in CI for https://jira.mongodb.org/browse/NODE-3998.
Is there new documentation needed for these changes?
No.
What is the motivation for this change?
Double check the following
npm run check:lint
scripttype(NODE-xxxx)[!]: description
feat(NODE-1234)!: rewriting everything in coffeescript