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

meteorMethods callbacks not called, if Meteor.Error thrown #564

Closed
arggh opened this issue Dec 14, 2016 · 4 comments
Closed

meteorMethods callbacks not called, if Meteor.Error thrown #564

arggh opened this issue Dec 14, 2016 · 4 comments
Labels

Comments

@arggh
Copy link
Contributor

arggh commented Dec 14, 2016

I'm not sure if I misunderstood the docs or what, but..

it seems if I throw an error, or if any of the event hooks throws an error, the meteorMethod's callback doesn't get called.

Repro:
https://github.com/arggh/astronomy-method-issue

@arggh
Copy link
Contributor Author

arggh commented Dec 14, 2016

From the docs:

const User = Class.create({
  name: 'User',
  /* ... */
  fields: {
    firstName: String,
    lastName: String
  },
  meteorMethods: {
    rename(firstName, lastName) {
      this.firstName = firstName;
      this.lastName = lastName;
      return this.save();
    }
  }
});

then:

const user = User.findOne();
user.rename('John', 'Smith', (err, result) => {
});

Now, if there is also this (doesn't have to be extend, can be in the actual Class declaration):

User.extend({
   events: {
    beforeUpdate: (e) {
       const user = e.currentTarget;
       if (user.isModified('firstName')) {
           throw new Meteor.Error('not-allowed');
       }
    }
  }
});

Then our callback doesn't get called, when calling user.rename.

@arggh arggh changed the title Errors not returned in meteorMethods callbacks meteorMethods callbacks not called, if Meteor.Error thrown Dec 14, 2016
@lukejagodzinski
Copy link
Member

Yes in deed, it seems to be a bug but it only happens when error is throw on the client, when it's throw on the server, callback gets called. It should be easy fix.

@lukejagodzinski
Copy link
Member

Fixed. Today I will release a new version

@arggh
Copy link
Contributor Author

arggh commented Dec 18, 2016

Great, thanks!

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

No branches or pull requests

2 participants