{"action":"created","issue":{"url":"https://api.github.com/repos/yelouafi/redux-saga/issues/78","repository_url":"https://api.github.com/repos/yelouafi/redux-saga","labels_url":"https://api.github.com/repos/yelouafi/redux-saga/issues/78/labels{/name}","comments_url":"https://api.github.com/repos/yelouafi/redux-saga/issues/78/comments","events_url":"https://api.github.com/repos/yelouafi/redux-saga/issues/78/events","html_url":"https://github.com/yelouafi/redux-saga/issues/78","id":131403699,"number":78,"title":"Forked subtasks should be cancelled when parent is cancelled (?)","user":{"login":"slorber","id":749374,"avatar_url":"https://avatars.githubusercontent.com/u/749374?v=3","gravatar_id":"","url":"https://api.github.com/users/slorber","html_url":"https://github.com/slorber","followers_url":"https://api.github.com/users/slorber/followers","following_url":"https://api.github.com/users/slorber/following{/other_user}","gists_url":"https://api.github.com/users/slorber/gists{/gist_id}","starred_url":"https://api.github.com/users/slorber/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/slorber/subscriptions","organizations_url":"https://api.github.com/users/slorber/orgs","repos_url":"https://api.github.com/users/slorber/repos","events_url":"https://api.github.com/users/slorber/events{/privacy}","received_events_url":"https://api.github.com/users/slorber/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-02-04T16:38:24Z","updated_at":"2016-02-04T16:46:41Z","closed_at":null,"body":"Imagine I have Task1 that forks Task2 that forks Task3\r\n\r\nNow I cancel Task1, which cause a `SagaCancellationException` inside Task1. \r\nBut by default seems forked tasks Task2 and Task3 are not cancelled and can stay alive even if the parent Task1 is cancelled.\r\n\r\nIs it supposed to be handled by redux-saga, or should I propagate the cancellation myself to forked subtasks?\r\n\r\nWith this code I successfully propagate the cancellation to subtasks but it requires additional boilerplate:\r\n\r\n```javascript\r\nexport default function* task1() {\r\n  let subtasks = [];\r\n  try {\r\n    subtasks.push(yield fork(task2));\r\n    subtasks.push(yield fork(task3));\r\n    while ( true ) {\r\n      yield take(\"SOME_EVENT_THAT_RESTART_SUBTASKS\");\r\n      yield subtasks.map(cancel);\r\n      subtasks = [];\r\n      subtasks.push(yield fork(task2));\r\n      subtasks.push(yield fork(task3));\r\n    }\r\n  }\r\n  catch(e) {\r\n    if ( e instanceof SagaCancellationException ) yield subtasks.map(cancel);\r\n    else throw e;\r\n  }\r\n}\r\n```\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/yelouafi/redux-saga/issues/comments/179939864","html_url":"https://github.com/yelouafi/redux-saga/issues/78#issuecomment-179939864","issue_url":"https://api.github.com/repos/yelouafi/redux-saga/issues/78","id":179939864,"user":{"login":"yelouafi","id":5453835,"avatar_url":"https://avatars.githubusercontent.com/u/5453835?v=3","gravatar_id":"","url":"https://api.github.com/users/yelouafi","html_url":"https://github.com/yelouafi","followers_url":"https://api.github.com/users/yelouafi/followers","following_url":"https://api.github.com/users/yelouafi/following{/other_user}","gists_url":"https://api.github.com/users/yelouafi/gists{/gist_id}","starred_url":"https://api.github.com/users/yelouafi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yelouafi/subscriptions","organizations_url":"https://api.github.com/users/yelouafi/orgs","repos_url":"https://api.github.com/users/yelouafi/repos","events_url":"https://api.github.com/users/yelouafi/events{/privacy}","received_events_url":"https://api.github.com/users/yelouafi/received_events","type":"User","site_admin":false},"created_at":"2016-02-04T16:46:41Z","updated_at":"2016-02-04T16:46:41Z","body":"Actual behavior propagates cancellation only to the current effect; i.e. where the Saga is blocked. For subtasks, it means the cancellation propagates only to called ones but not forked ones (since the saga is not blocked on them).\r\n\r\nDo you think cancellation should be automatically propagated to forked tasks also ? \r\n\r\nIt's true that until now I also only encountered cases when the propagation should be propagated. But aren't there cases where the propagation is not desirable ?\r\n\r\nOr should we perhaps provide the 2 options (like an additional method `spawn` which automatically propagate the cancellation) ?"}}