{"action":"created","issue":{"url":"https://api.github.com/repos/redux-saga/redux-saga/issues/1598","repository_url":"https://api.github.com/repos/redux-saga/redux-saga","labels_url":"https://api.github.com/repos/redux-saga/redux-saga/issues/1598/labels{/name}","comments_url":"https://api.github.com/repos/redux-saga/redux-saga/issues/1598/comments","events_url":"https://api.github.com/repos/redux-saga/redux-saga/issues/1598/events","html_url":"https://github.com/redux-saga/redux-saga/issues/1598","id":358580436,"node_id":"MDU6SXNzdWUzNTg1ODA0MzY=","number":1598,"title":"Memory leak when using actionChannel() with takeLatest()","user":{"login":"cgav","id":580894,"node_id":"MDQ6VXNlcjU4MDg5NA==","avatar_url":"https://avatars0.githubusercontent.com/u/580894?v=4","gravatar_id":"","url":"https://api.github.com/users/cgav","html_url":"https://github.com/cgav","followers_url":"https://api.github.com/users/cgav/followers","following_url":"https://api.github.com/users/cgav/following{/other_user}","gists_url":"https://api.github.com/users/cgav/gists{/gist_id}","starred_url":"https://api.github.com/users/cgav/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cgav/subscriptions","organizations_url":"https://api.github.com/users/cgav/orgs","repos_url":"https://api.github.com/users/cgav/repos","events_url":"https://api.github.com/users/cgav/events{/privacy}","received_events_url":"https://api.github.com/users/cgav/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/redux-saga/redux-saga/milestones/1","html_url":"https://github.com/redux-saga/redux-saga/milestone/1","labels_url":"https://api.github.com/repos/redux-saga/redux-saga/milestones/1/labels","id":2822174,"node_id":"MDk6TWlsZXN0b25lMjgyMjE3NA==","number":1,"title":"v1","description":"","creator":{"login":"Andarist","id":9800850,"node_id":"MDQ6VXNlcjk4MDA4NTA=","avatar_url":"https://avatars2.githubusercontent.com/u/9800850?v=4","gravatar_id":"","url":"https://api.github.com/users/Andarist","html_url":"https://github.com/Andarist","followers_url":"https://api.github.com/users/Andarist/followers","following_url":"https://api.github.com/users/Andarist/following{/other_user}","gists_url":"https://api.github.com/users/Andarist/gists{/gist_id}","starred_url":"https://api.github.com/users/Andarist/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Andarist/subscriptions","organizations_url":"https://api.github.com/users/Andarist/orgs","repos_url":"https://api.github.com/users/Andarist/repos","events_url":"https://api.github.com/users/Andarist/events{/privacy}","received_events_url":"https://api.github.com/users/Andarist/received_events","type":"User","site_admin":false},"open_issues":8,"closed_issues":37,"state":"open","created_at":"2017-10-07T23:26:46Z","updated_at":"2018-09-14T08:48:32Z","due_on":null,"closed_at":null},"comments":4,"created_at":"2018-09-10T11:25:29Z","updated_at":"2018-09-14T16:36:18Z","closed_at":null,"author_association":"NONE","body":"### Steps to reproduce\r\n\r\n#### Description of the bug/issue\r\n\r\nI have observed a 'channel overflow' error using `redux-saga@0.16.0` when running the following code snippet. After upgrading to `redux-saga@1.0.0-beta.1` the overflow disappears but the channels are not being closed after `takeLatest()` is (or should have been) cancelling `takeLatestSaga`:\r\n\r\n```javascript\r\nconst actionChannelSaga = function*(id) {\r\n  console.log(`### Channel saga for ACTION_FOR_TAKE_LATEST ${id}`);\r\n};\r\n\r\nconst takeLatestSaga = function*(action) {\r\n  const { id } = action.payload;\r\n  const channel = yield actionChannel('ACTION_FOR_CHANNEL');\r\n  \r\n  const originalPut = channel.put;\r\n  channel.put = (...args) => {\r\n    console.log(`channel.put() called for id ${id}`);\r\n    originalPut(...args);\r\n  };\r\n\r\n  while (true) {\r\n    const action = yield take(channel);\r\n    yield call(actionChannelSaga, id, action);\r\n    yield take('ACTION_THAT_NEVER_COMES');\r\n    console.log('>>> We should not reach this point');\r\n  }\r\n};\r\n\r\nconst startSaga = function*() {\r\n  yield takeLatest('ACTION_FOR_TAKE_LATEST', takeLatestSaga);\r\n\r\n  for (let i = 0; i < 10; i++) {\r\n    yield put({ type: 'ACTION_FOR_TAKE_LATEST', payload: { id: i } });\r\n    yield call(delay, 10);\r\n    yield put({ type: 'ACTION_FOR_CHANNEL' });\r\n  }\r\n};\r\n\r\nsagaMiddleware.run(startSaga);\r\n```\r\n\r\n#### Steps to reproduce the bug/issue\r\n\r\n1. Run the snippet above (see codesandbox.io link below)\r\n...\r\n\r\n#### Example\r\nhttps://codesandbox.io/s/vn3ljqq9y0\r\n\r\n### Actual results\r\n\r\nThe snippet above produces the following logs:\r\n```\r\nchannel.put() called for id 0\r\n### Channel saga for ACTION_FOR_TAKE_LATEST 0\r\nchannel.put() called for id 0\r\nchannel.put() called for id 1\r\n### Channel saga for ACTION_FOR_TAKE_LATEST 1\r\nchannel.put() called for id 0\r\nchannel.put() called for id 1\r\nchannel.put() called for id 2\r\n### Channel saga for ACTION_FOR_TAKE_LATEST 2\r\nchannel.put() called for id 0\r\nchannel.put() called for id 1\r\nchannel.put() called for id 2\r\nchannel.put() called for id 3\r\n### Channel saga for ACTION_FOR_TAKE_LATEST 3\r\nchannel.put() called for id 0\r\nchannel.put() called for id 1\r\nchannel.put() called for id 2\r\nchannel.put() called for id 3\r\nchannel.put() called for id 4\r\n### Channel saga for ACTION_FOR_TAKE_LATEST 4\r\n...\r\n```\r\n\r\n### The Expected results\r\n\r\nRunning the snippet above, I'd expect the `actionChannel` to be closed after `takeLatestSaga()` is being cancelled and to see those logs instead:\r\n```\r\nchannel.put() called for id 0\r\n### Channel saga for ACTION_FOR_TAKE_LATEST 0\r\nchannel.put() called for id 1\r\n### Channel saga for ACTION_FOR_TAKE_LATEST 1\r\nchannel.put() called for id 2\r\n### Channel saga for ACTION_FOR_TAKE_LATEST 2\r\nchannel.put() called for id 3\r\n### Channel saga for ACTION_FOR_TAKE_LATEST 3\r\nchannel.put() called for id 4\r\n### Channel saga for ACTION_FOR_TAKE_LATEST 4\r\n...\r\n```\r\n\r\n### Environment information\r\n- redux-saga 1.0.0-beta.1\r\n- redux 3.7.2\r\n"},"comment":{"url":"https://api.github.com/repos/redux-saga/redux-saga/issues/comments/421414920","html_url":"https://github.com/redux-saga/redux-saga/issues/1598#issuecomment-421414920","issue_url":"https://api.github.com/repos/redux-saga/redux-saga/issues/1598","id":421414920,"node_id":"MDEyOklzc3VlQ29tbWVudDQyMTQxNDkyMA==","user":{"login":"shinima","id":5550931,"node_id":"MDQ6VXNlcjU1NTA5MzE=","avatar_url":"https://avatars3.githubusercontent.com/u/5550931?v=4","gravatar_id":"","url":"https://api.github.com/users/shinima","html_url":"https://github.com/shinima","followers_url":"https://api.github.com/users/shinima/followers","following_url":"https://api.github.com/users/shinima/following{/other_user}","gists_url":"https://api.github.com/users/shinima/gists{/gist_id}","starred_url":"https://api.github.com/users/shinima/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shinima/subscriptions","organizations_url":"https://api.github.com/users/shinima/orgs","repos_url":"https://api.github.com/users/shinima/repos","events_url":"https://api.github.com/users/shinima/events{/privacy}","received_events_url":"https://api.github.com/users/shinima/received_events","type":"User","site_admin":false},"created_at":"2018-09-14T16:36:18Z","updated_at":"2018-09-14T16:36:18Z","author_association":"COLLABORATOR","body":"I found that auto closing is undesirable when we use `spawn` effects. The detached children may still use a channel from the parent while the parent task is complete."}}
{"actor":{"display_login":"shinima"}}