-
Notifications
You must be signed in to change notification settings - Fork 1.8k
refactor(NODE-4631): change_stream, gridfs to use maybeCallback #3406
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
refactor(NODE-4631): change_stream, gridfs to use maybeCallback #3406
Conversation
547b09a
to
e83ae11
Compare
e83ae11
to
68eba0d
Compare
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.
General comment - I think we should use maybeCallback
in cases we don't use maybePromise now, but use the promise provider. We should encapsulate all knowledge of the promise provider into maybeCallback.
@@ -35,7 +35,6 @@ const options: MongoClientOptions = { | |||
promoteBuffers: false, | |||
authMechanism: 'SCRAM-SHA-1', | |||
forceServerObjectId: false, | |||
promiseLibrary: Promise, |
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.
why did you remove promiseLibrary from these tests? it's deprecated but that shouldn't matter
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.
It was setting the promise lib to something other than null, so it had side effects, even though each MongoClient accepts a promiseLib it modifies it for the process globally
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 wouldn't expect that to cause issues for our ts tests though, because they'll never actually run?
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.
Oh sorry yea this one doesn't effect anything, the other one is the runtime usage. We have the explicit type test to check that promiseLibrary is deprecated, I think we can remove this from here now which is just a selection of MongoOptions. (one less search and replace)
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.
leaving this thread open for context but I consider this resolved
src/promise_provider.ts
Outdated
@@ -4,11 +4,11 @@ import { MongoInvalidArgumentError } from './error'; | |||
const kPromise = Symbol('promise'); | |||
|
|||
interface PromiseStore { | |||
[kPromise]?: PromiseConstructor; | |||
[kPromise]: PromiseConstructor | 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.
haven't reviewed this file yet - pending team discussion about breaking changes here
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.
most comments addressed/resolved, some questions and suggestions remaining
@@ -35,7 +35,6 @@ const options: MongoClientOptions = { | |||
promoteBuffers: false, | |||
authMechanism: 'SCRAM-SHA-1', | |||
forceServerObjectId: false, | |||
promiseLibrary: Promise, |
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 wouldn't expect that to cause issues for our ts tests though, because they'll never actually run?
@@ -35,7 +35,6 @@ const options: MongoClientOptions = { | |||
promoteBuffers: false, | |||
authMechanism: 'SCRAM-SHA-1', | |||
forceServerObjectId: false, | |||
promiseLibrary: Promise, |
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.
leaving this thread open for context but I consider this resolved
a54b2ef
to
f93126c
Compare
a5ad648
to
1643501
Compare
|
||
if (this.s.executed) { | ||
return handleEarlyError(new MongoBatchReExecutionError(), callback); | ||
// eslint-disable-next-line @typescript-eslint/require-await |
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.
Are we calling maybePromise
twice to handle these errors because executeOperation
takes a callback? Why not just promisify execute operation?
maybeCallback(async () => {
...
return promisify(execute_operation)(....)
})
This approach might be preferable as well, because once you make execute_operation return a promise, you won't need to refactor this method much except just to remove the call to promisify.
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.
Wrapping the execOp in maybeCallback (naively, so that's likely why) messes with session allocation because it makes the maybePromise logic run. We can add a note to the refactor exec operation refactor ticket to comeback here, or I can revert the changes here and we can do it altogether.
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.
We'll tackle this once execute_operation has been refactored
511ddce
to
70b8e76
Compare
Co-authored-by: Daria Pardue <[email protected]>
70b8e76
to
bf668c2
Compare
@baileympearson this is unblocked with the recent release. I've rebased so we can double check we're up to date on changes while we held off on this. (just an FYI no rush at all!) |
…odb#3406) Co-authored-by: Daria Pardue <[email protected]>
Description
What is changing?
Double check the following
npm run check:lint
script<type>(NODE-xxxx)<!>: <description>