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

Meteor: 3.0.0-rc1 Package: allow-deny -> client side collection insert/update/remove not working as expected #13143

Open
acemtp opened this issue May 14, 2024 · 2 comments
Labels
Meteor 3 relates to Meteor 3
Milestone

Comments

@acemtp
Copy link
Contributor

acemtp commented May 14, 2024

When executing the following line on the client with meteor 3, it should work since minimongo doesn't require async function calls.

Meteor.users.update(Meteor.userId(), { $set: { 'profile.ok': 1 }})

It generates this error on the server:

 Exception while invoking method '/users/update' Error: findOne +  is not available on the server. Please use findOneAsync() instead.
     at Object.ret.<computed> (packages/mongo/remote_collection_driver.js:52:15)
     at Object.<anonymous> (packages/matb33:collection-hooks/findone.js:27:22)
     at Object.collection.<computed> [as findOne] (packages/matb33:collection-hooks/collection-hooks.js:116:21)
     at CollectionPrototype._validatedUpdate (packages/allow-deny/allow-deny.js:485:32)
     at MethodInvocation.m.<computed> (packages/allow-deny/allow-deny.js:193:46)

The reason is that in allow-deny.js of the AllowDeny package, the old method _validatedUpdate() is called but contains a findOne that is not Async.

Current Fix:

On our server code, we added this lines to override the deprecated function

if (Meteor.isServer) {
  Mongo.Collection.prototype._validatedInsert = Mongo.Collection.prototype._validatedInsertAsync;
  Mongo.Collection.prototype._validatedUpdate = Mongo.Collection.prototype._validatedUpdateAsync;
  Mongo.Collection.prototype._validatedRemove = Mongo.Collection.prototype._validatedRemoveAsync;
}

Solution 1:

Update the code of _validatedInsert _validatedUpdate _validatedRemove in allow-deny.js to handle async methods

Solution 2 (better):

remove _validatedInsert _validatedUpdate _validatedRemove function and always use _validatedInsertAsync _validatedUpdateAsync _validatedRemoveAsync in both case update and updateAsync.

@StorytellerCZ StorytellerCZ added this to the Release 3.0 milestone May 14, 2024
@StorytellerCZ StorytellerCZ added the Meteor 3 relates to Meteor 3 label May 14, 2024
@nachocodoner
Copy link
Member

Thank you for the report.

It's surprising we have not run into this issue in our automated test coverage, but we'll make sure to add it and include the fix in our nexts RCs.

@denihs
Copy link
Contributor

denihs commented May 16, 2024

Yes, it is strange... Anyways, let's fix it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Meteor 3 relates to Meteor 3
Projects
None yet
Development

No branches or pull requests

4 participants