{"action":"created","issue":{"url":"https://api.github.com/repos/apollographql/react-apollo/issues/2477","repository_url":"https://api.github.com/repos/apollographql/react-apollo","labels_url":"https://api.github.com/repos/apollographql/react-apollo/issues/2477/labels{/name}","comments_url":"https://api.github.com/repos/apollographql/react-apollo/issues/2477/comments","events_url":"https://api.github.com/repos/apollographql/react-apollo/issues/2477/events","html_url":"https://github.com/apollographql/react-apollo/issues/2477","id":367319835,"node_id":"MDU6SXNzdWUzNjczMTk4MzU=","number":2477,"title":"Inifinite calling of onError in query hoc","user":{"login":"stefan-krajnik","id":16229997,"node_id":"MDQ6VXNlcjE2MjI5OTk3","avatar_url":"https://avatars3.githubusercontent.com/u/16229997?v=4","gravatar_id":"","url":"https://api.github.com/users/stefan-krajnik","html_url":"https://github.com/stefan-krajnik","followers_url":"https://api.github.com/users/stefan-krajnik/followers","following_url":"https://api.github.com/users/stefan-krajnik/following{/other_user}","gists_url":"https://api.github.com/users/stefan-krajnik/gists{/gist_id}","starred_url":"https://api.github.com/users/stefan-krajnik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stefan-krajnik/subscriptions","organizations_url":"https://api.github.com/users/stefan-krajnik/orgs","repos_url":"https://api.github.com/users/stefan-krajnik/repos","events_url":"https://api.github.com/users/stefan-krajnik/events{/privacy}","received_events_url":"https://api.github.com/users/stefan-krajnik/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-10-05T18:26:33Z","updated_at":"2018-10-17T13:35:04Z","closed_at":null,"author_association":"NONE","body":"<!--\r\n  Thanks for filing an issue on React Apollo!\r\n\r\n  Please make sure that you include the following information to ensure that your issue is actionable.\r\n\r\n  If you don't follow the template, your issue may end up being closed without anyone looking at it carefully, because it is not actionable for us without the information in this template.\r\n\r\n  If you're filing a feature request, you do not need to follow the outline below, but please include \"feature idea\" in the title and include a specific example in which that feature would be useful.\r\n-->\r\n\r\n**Intended outcome:**\r\nI expect to `onError` be called only once when a response is received.\r\n\r\n<!--\r\nWhat you were trying to accomplish when the bug occurred, and as much code as possible related to the source of the problem.\r\n-->\r\n\r\n**Actual outcome:**\r\nI have an mutation (`@client`) which I call in `onError`, but the mutation seems to be triggering some process in which `onError` (with same error from the request call) is called again\r\n<!--\r\nA description of what actually happened, including a screenshot or copy-paste of any related error messages, logs, or other output that might be related. Places to look for information include your browser console, server console, and network logs. Please avoid non-specific phrases like “didn’t work” or “broke”.\r\n-->\r\n\r\n**How to reproduce the issue:**\r\nHere is the block of code I'm using. \r\n_Note: if I don't call `createNotification` everything works as expected_\r\n```\r\nexport default compose(\r\n  graphql(createNotificationMutation, { name: 'createNotification' }),\r\n  graphql(someQuery, {\r\n    name: 'someQuery',\r\n    options: ({ createNotification }) => ({\r\n      variables: {\r\n        // ....\r\n      },\r\n      notifyOnNetworkStatusChange: true,\r\n      onError: (err) => {\r\n        createNotification({\r\n          variables: {\r\n            data: {\r\n              text: err.message,\r\n              isError: true,\r\n            },\r\n          },\r\n        })\r\n      },\r\n    }),\r\n  }),\r\n)(MyComponent)\r\n```\r\n\r\n<!--\r\nIf possible, please create a reproduction using https://github.com/apollographql/react-apollo-error-template and link to it here. If you prefer an in-browser way to create reproduction, try https://codesandbox.io/s/7361K9q6w\r\n\r\nInstructions for how the issue can be reproduced by a maintainer or contributor. Be as specific as possible, and only mention what is necessary to reproduce the bug. If possible, try to isolate the exact circumstances in which the bug occurs and avoid speculation over what the cause might be.\r\n-->\r\n\r\n**Version**\r\n\r\n- apollo-client@<version number> - I don't have direct apollo-client dependency \r\n- react-apollo@2.2.4\r\n- apollo-boost@0.1.15\r\n"},"comment":{"url":"https://api.github.com/repos/apollographql/react-apollo/issues/comments/430630508","html_url":"https://github.com/apollographql/react-apollo/issues/2477#issuecomment-430630508","issue_url":"https://api.github.com/repos/apollographql/react-apollo/issues/2477","id":430630508,"node_id":"MDEyOklzc3VlQ29tbWVudDQzMDYzMDUwOA==","user":{"login":"manurg","id":591325,"node_id":"MDQ6VXNlcjU5MTMyNQ==","avatar_url":"https://avatars0.githubusercontent.com/u/591325?v=4","gravatar_id":"","url":"https://api.github.com/users/manurg","html_url":"https://github.com/manurg","followers_url":"https://api.github.com/users/manurg/followers","following_url":"https://api.github.com/users/manurg/following{/other_user}","gists_url":"https://api.github.com/users/manurg/gists{/gist_id}","starred_url":"https://api.github.com/users/manurg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/manurg/subscriptions","organizations_url":"https://api.github.com/users/manurg/orgs","repos_url":"https://api.github.com/users/manurg/repos","events_url":"https://api.github.com/users/manurg/events{/privacy}","received_events_url":"https://api.github.com/users/manurg/received_events","type":"User","site_admin":false},"created_at":"2018-10-17T13:35:04Z","updated_at":"2018-10-17T13:35:04Z","author_association":"NONE","body":"@olistic @stefan-krajnik \r\nI think this problem was implemented with https://github.com/apollographql/react-apollo/pull/2190\r\nIf you call `setState` within `onError` handler (which now also gets called within `Query`s `componentDidUpdate`, you create an infinite loop. IMHO this is unexpected.\r\n\r\nI created i little sandbox:\r\n[![Edit k04rq99845](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/k04rq99845)\r\n\r\nThis is the preview in the browser:\r\nhttps://k04rq99845.codesandbox.io/\r\n\r\nYou can force an error by blocking the call to `w5xlvm3vzz.lp.gql.zone/graphql` and hit reload\r\n<img width=\"409\" alt=\"block_request_url\" src=\"https://user-images.githubusercontent.com/591325/47089929-19e59f00-d222-11e8-84b8-4c3c2ecc628f.png\">\r\n<img width=\"586\" alt=\"infite_loop\" src=\"https://user-images.githubusercontent.com/591325/47089937-1f42e980-d222-11e8-9c6a-9a56edcbff9f.png\">\r\n"}}
{"actor":{"display_login":"manurg"}}