Skip to content

Containers swallow application errors and return cryptic errors back #319

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
sporto opened this issue May 21, 2015 · 7 comments
Open

Containers swallow application errors and return cryptic errors back #319

sporto opened this issue May 21, 2015 · 7 comments

Comments

@sporto
Copy link
Contributor

sporto commented May 21, 2015

In Marty 0.9

We have a container like:

var EmailsLoader = Marty.createContainer(Emails, {

    propTypes: {
        personId: PT.any.isRequired
    },

    listenTo: store,

    fetch: {
        emails() {
            const personId = this.props.personId;
            const fetch = store.for(this).fetchPersonEmails(personId);
            return fetch;
        }
    },

    failed(errors) {
        return <div>{errors}</div>;
    },

    pending() {
        return <div><Loader /></div>;
    }
});

export default EmailsLoader;

And a component like:

class Emails extends React.Component {

    render() {
        const emails = this.props.emails;

        return (
            <section className={classAdder('')}>
                ...
            </section>
        );
    }
}

Everything works well.

But if we introduce an error in the component:

class Emails extends React.Component {

    render() {
        const emails = this.props.emails;
        throw "Some error"
        return (
            <section className={classAdder('')}>
                ...
            </section>
        );
    }
}

Then we just see this in the browser:

Error: Invariant Violation: findComponentRoot(..., .0.1.1.0.1.1.0.0.0): Unable to find element. This probably means the DOM was unexpectedly mutated (e.g., by the browser), usually due to forgetting a <tbody> when using tables, nesting tags like <form>, <p>, or <a>, or using non-SVG elements in an <svg> parent. Try inspecting the child nodes of the element with React ID ``.

Which is pretty useless.

This happens with anything in the Container chain i.e. if there is an error in emailsQueries or emailsProviders, emailsStore or the rendered component

@jhollingworth
Copy link
Contributor

OK, I will investigate and get back to you

@idolizesc
Copy link

I'm experiencing this as well

@sporto
Copy link
Contributor Author

sporto commented May 27, 2015

This has gone away in 0.9.17, now I see proper errors :)

@sporto
Copy link
Contributor Author

sporto commented May 27, 2015

I'm still having some trouble with this. If I introduce an error in the store or component I see the error, e.g.

locally: function() {
    ...
    [].foo()
    ...
}
TypeError: [].foo is not a function

But if I introduce the error in the Container:

    fetch: {
        status() {
            ...
            [].foo()
            ...
        }
    },

I just see:

TypeError: inst is null

@sporto
Copy link
Contributor Author

sporto commented May 27, 2015

Correction, if I introduce the error in the component:

    render() {
        ...
        [].foo()
        ...
    }

I get:

"Fetch error" TypeError: prevComponentInstance is null

jhollingworth added a commit to martyjs/marty-lib that referenced this issue May 28, 2015
@jhollingworth
Copy link
Contributor

This is an odd one. I've seen this bug before myself but just tried to replicate it in a test and can't seem to. Will investigate further

@sporto
Copy link
Contributor Author

sporto commented May 28, 2015

@jhollingworth I would like to help replicating the issue, by any chance do you have a fiddle or plunkr with a minimum Marty app using 0.9?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants