Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

harryadel
Copy link
Contributor

@harryadel harryadel commented Apr 1, 2024

In our application we call _createUserCheckingDuplicates and I found out it's not async-friendly yet. Can we please add it to 2.16?

@nachocodoner nachocodoner mentioned this pull request Apr 2, 2024
7 tasks
@nachocodoner
Copy link
Member

Added on the list for 2.16.
#13066

}
const user = { services: {} };
return Accounts._createUserCheckingDuplicates({
return await Accounts._createUserCheckingDuplicates({
Copy link
Member

Choose a reason for hiding this comment

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

I believe it's a matter of taste, but usually, using return await isn't necessary. You can typically return the promise directly in an async function.

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 know it might seem redundant but it's just clear.

Copy link
Member

@nachocodoner nachocodoner left a comment

Choose a reason for hiding this comment

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

I think there are still changes needed to the proper adoption.

@jamauro
Copy link
Contributor

jamauro commented Apr 3, 2024

@harryadel out of curiosity, why do you call this internal method in your app?

@harryadel
Copy link
Contributor Author

@jamauro We've this unique case in our application where we have the user sha256 client-hashed password and some other meta data regarding the user document so we end up stitching these properties together and using an internal creation method (_createUserCheckingDuplicates in our case) to make the final user document and allow him to login.

…arryadel/meteor into fix/_checkForCaseInsensitiveDuplicates
@harryadel
Copy link
Contributor Author

harryadel commented Apr 8, 2024

@nachocodoner I ended up asyncfying addEmail and setUsername since they were using _checkForCaseInsensitiveDuplicates inside their functions.

On the 3.0 branch is this fixed? Is the accounts-password package completely free of sync db-calls??

@nachocodoner
Copy link
Member

On the 3.0 branch is this fixed? Is the accounts-password package completely free of sync db-calls??

It seems that is adapted actually. If you look into the release-3.0 branch you will see the code using async, and the ones you adapted here, already migrated.

In the changelog we keep the list of package's API that have been migrated to async, for instance, for the accounts-password package. So, your PR here will produce a breaking change for apps in Meteor 2.x, that make use of exposed API behaviors addEmail and setUsername which will be resolved as promise on next 2.16. But this migration will make ready for Meteor 3.x as stated above those are already async.

Alternatively we could have async versions for addEmailAsync and setUsernameAsync , the same way we have for Accounts.setPasswordAsync. But as they are migrated already as async in Meteor 3.x it may not be required.

cc @Grubba27, @denihs

@harryadel
Copy link
Contributor Author

harryadel commented Apr 8, 2024

Our philosophy so far has been to get everything asyncified, just like you mentioned with Accounts.setPasswordAsync so that when we run meteor update 3.0 there's very little to no work (the final step rather than it being another minor step.

Though my opinion on this isn't set in stone, let's see what Denis & Grubba has to say about this.

@Grubba27
Copy link
Contributor

Grubba27 commented Apr 8, 2024

I would go in the safe route here...

We decided to create those *Async APIs to help out the migration, and following that pattern here is the way to go.

We should focus on not breaking changes and making those breaking changes as easy as possible for those making the transition.

We could have addEmailAsync and setUsernameAsync, leaving those without an async name until 3.0, when addEmailAsync and setUsernameAsync become aliases to their non-Async counterparts.

// 2.x

Accounts.addEmail // <- sync
Accounts.addEmailAsync // <- resolves to promise

// 3.x

Accounts.addEmail // <- resolves to promise it is just an alias to the addEmailAsync
Accounts.addEmailAsync // <- resolves to promise

@nachocodoner
Copy link
Member

That makes sense. We didn't do the same for 3.x and instead change to async directly. But we may change this now, since I don't think compromise a lot. So, if you can adapt this @harryadel to use async versions instead, that would be great.

@harryadel
Copy link
Contributor Author

@nachocodoner so I'd duplicate the functions and create async alternatives so it doesn't break anything for 2.x or just change the variables names to use the async prefix?

@nachocodoner
Copy link
Member

I'd duplicate the functions and create async alternatives so it doesn't break anything for 2.x

This is better to stick into the convention. This way we won't force any breaking changes on the new update.

@nachocodoner
Copy link
Member

nachocodoner commented Apr 23, 2024

We plan to release this week 2.16.

@harryadel: Do you want to include this on release 2.16? How is the state of the feedback applied?

We should create async versions as stated here and keep easy migration with 3.x, #13076 (comment)

@harryadel
Copy link
Contributor Author

I had initially started this PR to help ease our migration to 3.0 but since we're already attempting to migrate to the latest RC it seizes to grant any value for us. Plus, it was discarded in 2.16 release.

@harryadel harryadel closed this Apr 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants