iron-meteor/iron-layout

"You called beginRendering again before calling endRendering", different cause

Closed this issue · 6 comments

I'll build the repro later today, but here's the bug:

Throws "You called beginRendering again before calling endRendering" error:

Router.map(function () {
    this.route('landingPage', {
        path: '/',
        action: function () {
            if (Meteor.user()) {
                this.redirect(nonreactiveFunctionThatGivesMeAPath());
            } else {
                this.render();
            }
        }
    });
});

Does not throw error, does the same thing:

Router.map(function () {
    this.route('landingPage', {
        path: '/',
        waitOn: function() {
            // Gets the user data
            return Meteor.subscribe('me');
        },
        action: function () {
            // Wait until I actually have data
            if (this.ready()) {
                // Now check if I'm logged in, non-reactively
                var user;
                Deps.nonreactive(function() {
                    user = Meteor.user();
                });
                if (user) {
                    this.redirect(nonreactiveFunctionThatGivesMeAPath());
                } else {
                    this.render();
                }
            } else {
                this.render();
            }
        }
    });
});

Thanks for reporting. This is probably a bit of a debugging exercise. I'll clone your repo when you have it and take a look. Thanks for doing that!

I can actually bug it out by doing a redirect in an action, period full stop, as long as I'm using anything reactive. My workaround is below.

        action: function () {

            if (this.ready()
                && Meteor.user()) {
                Meteor.defer(function() {
                    Router.go(nonreactiveFunctionThatGivesMeAPath(), {replaceState: true});
                });
            }

            this.render();
        }

Hey @doctorpangloss, A repro would be really helpful. This seems like it could be something that affects a lot of people so would prefer to fix the root issue. Do you have a github project I can take a look at? Doesn't need to be perfect.

Yeah I'm having trouble reproing it exactly. Just documenting my notes here. Thanks a lot, maybe I'll be able to fix it :)

Ok thanks. I just tried to reproduce this bug and was unable on devel (commit: 7993938). Also, just double checked that the controller should call the finishCurrentRenderingTransaction method before calling beginRendering() again. From a quick glance of the code I'm not sure how beginRendering could get called again before the finishCurrentRenderingTransaction is called. Are you on the latest devel commit?

Alright I can repro different bugs, I'm posting it to the right place now