Meteor 3 beta.0: Throwing an error inside of a meteor method doesn't throw on the client
ToyboxZach opened this issue · comments
ToyboxZach commented
Found a breaking change from the upgrade to version 3 that doesn't seem like it was intentional:
On Server:
Meteor.methods({
throwAnError:function() {
throw "Error";
}
}
On client:
console.log("THROW", Meteor.call("throwAnError"));
On Meteor 2, this will correctly throw an error on the client that can be caught and handled, but on Meteor 3 it is returning a promise.
If you await the promise it will correctly throw, but this is a breaking change, and I am not sure if it was necessary?
If it was a necessary change, I think the types should be updated where if you don't have a callback it knows it is asynchronous and it needs to be called out in the change log
To catch all the times this should have been async I locally changed the types to:
type NotFunc<T> = Exclude<T, Function>;
function call<T>(name: string, ...args: [...any, (e: Meteor.Error, res: T) => any]): void;
function call(name: string, ...args: [...any, NotFunc<any>]): Promise<any>;
function call(name: string): Promise<any>;