[SOLVED] Minor bug in blaze when using dynamic import of templates

In a medium sized project, I still use Blaze, and still use Iron-Router, but I decided to move ahead with some code-splitting (dynamic imports) of Blaze templates based on the path.

It works great, but I have noticed a minor bug that only occurs occasionally. It seems that after importing the template that it sometimes runs some of the helpers before the data is ready. This generates errors because ‘this’ is not set up yet. It results in binding errors.

But then it continues and runs the template correctly, and the result is what i expected.

Anyone else seen this, and are there any suggestions?

Do you have a repro? Ive used a similar stack with dynamic imports for years and had no problems.

thanks. no i don’t have a repo, unfortunately. Would the path definition help?

What’s a path definition?

sorry. i mean my iron router route definition.

I doubt that will help alone, at a minimum we’d need to see the blaze template including the filename where it so stored. The route definition and where that is stored, and if it’s declared somewhere else the dynamic import too. Really, we need reproduction instructions since this seems like it might be very specific.

I’ve also used dynamic imports and route splitting with Blaze for a couple of years without this issue (plenty of other issues, most of which were my own fault :laughing: )

Can you post the code of the template being imported? helpers not having access to this sounds like a clue

Thanks for everyone’s help. I decided to cleanup my router definition code, and the problem seem to be resolved. I was likely doing multiple renders on that route.

1 Like