kadirahq / flow-router

Carefully Designed Client Side Router for Meteor
MIT License
1.09k stars 195 forks source link

Setting global subscription breaks production build #703

Open jfraboni opened 7 years ago

jfraboni commented 7 years ago

We're running METEOR@1.3.2.4.

Adding a global route subscription, as per the documentation, results in failures in all routes, ie, a blank page. This only happens when the app is deployed with --production. It does seem to cause issues when deployed with --debug.

We added the subscription like so:

FlowRouter.subscriptions = function() { this.register('subscriptionRoles', Meteor.subscribe('roles')); };

I'm not sure why this happens only in a production build, but if I understand correctly, fast rendering won't work without a route level subscription (or does it, who knows), so it would be great if the global subscription feature worked as expected because adding subs per route is cumbersome. Would be great if you could add them to a route group, instead of only globally or locally.

Also, while I'm yapping about route level subscriptions, it seems from conversations around on blogs and such that you're moving away from route level subscriptions, I think this is a mistake: it's much simpler, more organized, less code to manage and therefore less error prone to check auth at the route level. I think you should allow developers the choice.