kadirahq / flow-router

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

Callback for Meteor.call fails to fire most of the time with flow-router-ssr #543

Open kareems opened 8 years ago

kareems commented 8 years ago

I haven't yet figured out the underlying cause, but about 95% of the time, with the flow-router-ssr package, the callbacks to all my uses of Meteor.call(…) never fire. No errors get thrown on the client or the server — it's as if the callback doesn't exist. If I do meteor remove kadira:flow-router-ssr and meteor add kadira:flow-router, the problem instantly goes away. This happens whether or not I use FlowRouter.setPageCacheTimeout(…).

I should say that I'm getting the "Warning: React attempted to reuse markup in a container but the checksum was invalid…" error when my pages first render. Seems unrelated, but I wanted to mention it because it's the only actual error I'm seeing be thrown (albeit on initial render, long before any uses of Meteor.call()).

kareems commented 8 years ago

Update: I've resolved that "React attempted to reuse markup…" error, but it didn't resolve this problem.

kareems commented 8 years ago

And a clarification: all the code in the Meteor.methods(…) functions that correspond to each use of Meteor.call(…) run properly. E.g. several of them are supposed to send an email on form submission, and that is all still working properly. It's just that the callback never runs.

kokjinsam commented 8 years ago

@kareems, I'm seeing "React attempted to reuse markup.." error in my app as well. Do you mind sharing how you managed to solve it?

kareems commented 8 years ago

@sammkj honestly I'm not quite sure! I was trying 3-4 things at once for something related, and suddenly found that it was fixed. I had been using a base.html file to generate a very basic <head> and <body>, and I think what resolved the problem was deleting <body> from that file and simply letting ReactLayout handle creating that tag.

This will soon be less relevant once things switch to react-mounter, but that requires Meteor 1.3 and I'd rather not mess with that until it's out of beta.

kokjinsam commented 8 years ago

@kareems , actually I'm using react-mounter and Meteor 1.3. I don't define any <body> in code. So probably you have done something else that fixed the problem, do you recall?

kareems commented 8 years ago

@sammkj I'm not sure, but perhaps one of these will help:

arunoda commented 8 years ago

We don't do anything special for Meteor.call on the server. If you are using Meteor.call, try not to use them while in the SSR.

This will help you: https://www.npmjs.com/package/react-no-ssr

kareems commented 8 years ago

@arunoda thanks, I'm only using Meteor.call in code that's inside the client/ directory (not components, just some separate utility functions), so the SSR shouldn't be able to see it. Maybe I just need to bite the bullet and upgrade to the 1.3 beta?

kareems commented 8 years ago

Just an update for anyone who stumbles across this, this problem is now resolved. Running a package update fixed it. I'm still not sure what the problem was, but the package versions before and after are below, so something in there fixed it ¯_(ツ)_/¯. The project has been on Meteor 1.2.1 all along.

kadira:flow-router-ssr@3.10.0 -> 3.11.2 meteorhacks:fast-render@2.11.0 -> 2.13.0 meteorhacks:inject-data@1.4.1 -> 2.0.0 meteorhacks:kadira@2.27.2 -> 2.28.2