Open chasemaier opened 5 years ago
Wouldn't the server portion of a Meteor Method still run if a client closes their browser? If there's some essential code that runs as a callback on the client when a Meteor Method returns to the client it may make sense to move that to the server.
Otherwise it's just client/UI updates no? Am I missing something else here?
Even if it is just UI/lower priority actions on complete, it would be nice to have the OPTION to monitor this. For example, if the optimistic UI leads a user to think an action is complete (checkbox becomes checked), I'd like to have the option to choose to warn the user that there is still pending activity in case the server ends up failing / returning an exception/error/etc after they have left.
You could make this as a ValidatedMethod mixin imo.
If I understand that package correctly, it looks like that would require all Meteor method be refactored to be wrapped/specially handled in that utility, which seems impractical for existing applications that have hundreds of existing vanilla Meteor.methods defined and used that are not already using that package.
If you have that amount of methods I highly recommend switching over anyway. We refactored about ~500 methods into ValidatedMethod in about a week and it provides a much easier way to deal with authenticated requests (no repeated function calls in every method), roles (no manual finding of roles) and provides testable code as you can export each one separately instead of adding to a global variable among other things. Your use case would be a simple addition of a mixin into the method definition.
Try checking Meteor.connection._outstandingMethodBlocks.length > 0
We recently ran into an issue where users would close their browser tabs prior to in-progress Meteor methods being completed (and their callbacks having run). I'd be interested in a way to check, at a global level, how many Meteor methods have been invoked but have not yet returned data/errors.
With this
window.onbeforeunload
could be used to warn the user that work might be lost if they navigate away at that time.