-
Notifications
You must be signed in to change notification settings - Fork 786
All Errors Catched #57
Comments
@johnthepink didn't you run into this case as well? |
@timsuchanek do you have some code I can use to replicate and write a test? Where is the child component failing and what is |
As soon as I can replicate I'll fix ASAP! |
For instance: it('doesn\'t catch all errors of children ', () => {
const store = createStore(() => ({ }));
const query = gql`
query people {
allPeople(first: 1) {
people {
name
}
}
}
`;
const data = {
allPeople: {
people: [
{
name: 'Luke Skywalker',
},
],
},
};
const networkInterface = mockNetworkInterface({
request: { query },
result: { data },
});
const client = new ApolloClient({
networkInterface,
});
const mapQueriesToProps = () => ({
errorTest: {
query,
},
});
let fail: any;
class ErrorChild2 extends React.Component<any, any> {
render(){
return (
<div>
{(() => {
return fail.test.foobar;
})()}
<Passthrough {...this.props} />;
</div>
)
}
}
class ErrorChild1 extends React.Component<any, any> {
render(){
return fail.test.foobar;;
}
}
@connect({ mapQueriesToProps })
class Container1 extends React.Component<any, any> {
render() {
return <ErrorChild1 {...this.props} />;
}
};
@connect({ mapQueriesToProps })
class Container2 extends React.Component<any, any> {
render() {
return <ErrorChild2 {...this.props} />;
}
};
const mountMethod1 = () => {
return mount(
<ProviderMock store={store} client={client}>
<Container1 pass='through' baz={50} />
</ProviderMock>
);
}
const mountMethod2 = () => {
return mount(
<ProviderMock store={store} client={client}>
<Container2 pass='through' baz={50} />
</ProviderMock>
);
}
expect(mountMethod1).to.throw;
expect(mountMethod2).to.throw;
}); Correctly passes? So two different error types both throw correctly |
Hmm of course when I try to create a minimal example, also all errors throw correctly. So I am using this boilerplate: https://github.com/graphcool-examples/react-apollo-todo-example Probably some other side effects are involved in interfering the proper error propagation. My conclusion was that the problem should be As soon as I have a reproducible example, I'll post it here |
@timsuchanek I have been running in to this issue as well. I'll do some digging. |
@timsuchanek would you be willing to share the class that isn't throwing errors in your app? |
@timsuchanek it looks like our issue didn't have to do with Here is the open issue on the react repo facebook/react#2461 For our project, I added react-transform-catch-errors, and altered our babel settings, and now we have the errors that you would expect on components using I know you mentioned you were using that boilerplate. It doesn't look like it includes a way to deal with catching the errors in react lifecycle functions. So maybe that will help? |
Hey guys, thanks for the input so far! if (this.props.data.errors) {
console.error(this.props.data.errors.stack);
} |
This gist could help from @jlevycpa: https://gist.github.com/jlevycpa/d681974915b8ccec10d378a4736af24c |
Here is a repro that should help. See the Readme for details. I've never put something like this together before so any feedback is appreciated. |
I updated to the latest version of react-apollo but I'm still seeing this issue. When I update the reproduction I posted above, the behavior changes slightly. The behavior of an error in the @jbaxleyiii did you try running the reproduction with the update? Did you have different results? Maybe I didn't update correctly or something? |
still not fixed |
Is it possible that this line is the problem? It looks like the rendered child is getting stored instead of being returned directly. I'm wondering if that is breaking the call stack instead of letting the error bubble all the way up through the return calls in the render methods. If I have time I will test this theory. It looks like the reason for storing the rendered child is to prevent re-renders. But isn't that what ShouldComponentUpdate is for? |
@jbaxleyiii not sure if you have already started on this bug, but I believe the test here has a logic bug in it: https://github.com/apollostack/react-apollo/blob/master/test/client/connect/queries.tsx#L1965 count gets incremented to 1 the first time render gets hit with data.loading set to true Fixing that alone doesn't make the test a correct reproducible test, but it's a start. |
I still have this bug in latest version of Apollo. Using it together with redux.
It's not a network error. |
Update: It happens only if I use Apollo's reducer and middleware with redux. Without connecting it to my redux store I can see errors, but they are all caught in
@jbaxleyiii Why this issue is closed? |
@skuridin looks like this was a bug in apollo client that was reintroduced. I believe a fix is already in place for it in the next release. react-apollo as the issue point was refactored and fixed to correctly error. Including tests added to prevent this regression |
@jbaxleyiii does this still happen with 0.5.4? I'm not aware of any bug having been reintroduced. |
Is there any official docs about error handling in mutations? I've found one way — |
I am on 1.0.0-rc.5 of both Any render error causes apollo's query data to not appear, the error itself is swallowed. |
please help me; where use throw in this code:
|
When using the
connect
method fromreact-apollo
, all errors that occur in one of the child components, are catched by apollo and fail silently.Development gets nearly impossible then.
Any ideas why that could be the case?
Using
apollo-client 0.3.5
andreact-apollo 0.3.3
Thanks!
The text was updated successfully, but these errors were encountered: