{"action":"created","issue":{"url":"https://api.github.com/repos/fluture-js/Fluture/issues/292","repository_url":"https://api.github.com/repos/fluture-js/Fluture","labels_url":"https://api.github.com/repos/fluture-js/Fluture/issues/292/labels{/name}","comments_url":"https://api.github.com/repos/fluture-js/Fluture/issues/292/comments","events_url":"https://api.github.com/repos/fluture-js/Fluture/issues/292/events","html_url":"https://github.com/fluture-js/Fluture/issues/292","id":374598132,"node_id":"MDU6SXNzdWUzNzQ1OTgxMzI=","number":292,"title":"Cancel function not running in Future.parallel","user":{"login":"jonwhelan","id":7376957,"node_id":"MDQ6VXNlcjczNzY5NTc=","avatar_url":"https://avatars1.githubusercontent.com/u/7376957?v=4","gravatar_id":"","url":"https://api.github.com/users/jonwhelan","html_url":"https://github.com/jonwhelan","followers_url":"https://api.github.com/users/jonwhelan/followers","following_url":"https://api.github.com/users/jonwhelan/following{/other_user}","gists_url":"https://api.github.com/users/jonwhelan/gists{/gist_id}","starred_url":"https://api.github.com/users/jonwhelan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jonwhelan/subscriptions","organizations_url":"https://api.github.com/users/jonwhelan/orgs","repos_url":"https://api.github.com/users/jonwhelan/repos","events_url":"https://api.github.com/users/jonwhelan/events{/privacy}","received_events_url":"https://api.github.com/users/jonwhelan/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-10-27T02:43:07Z","updated_at":"2018-10-27T23:01:52Z","closed_at":null,"author_association":"NONE","body":"When calling Future.parallel, the cancellation function is not called on futures in the array that are placed after an already rejected future:\r\n\r\n```js\r\nconst makeFuture = (name) =>\r\n\tFuture((rej, res) => {\r\n\t\tsetTimeout(() => res(name), 100);\r\n\t\treturn () => {\r\n\t\t\tconsole.log(`cancelling ${name}`);\r\n\t\t}\r\n\t});\r\n\r\nFuture.parallel(Infinity, [\r\n\tmakeFuture('A'),\r\n\tFuture.reject(new Error),\r\n\tmakeFuture('B')\r\n]).fork(console.error, console.log);\r\n```\r\n\r\n```\r\nExpected:\r\n  'cancelling A'\r\n  'cancelling B'\r\n\r\nActual:\r\n  'cancelling A'\r\n```"},"comment":{"url":"https://api.github.com/repos/fluture-js/Fluture/issues/comments/433662332","html_url":"https://github.com/fluture-js/Fluture/issues/292#issuecomment-433662332","issue_url":"https://api.github.com/repos/fluture-js/Fluture/issues/292","id":433662332,"node_id":"MDEyOklzc3VlQ29tbWVudDQzMzY2MjMzMg==","user":{"login":"jonwhelan","id":7376957,"node_id":"MDQ6VXNlcjczNzY5NTc=","avatar_url":"https://avatars1.githubusercontent.com/u/7376957?v=4","gravatar_id":"","url":"https://api.github.com/users/jonwhelan","html_url":"https://github.com/jonwhelan","followers_url":"https://api.github.com/users/jonwhelan/followers","following_url":"https://api.github.com/users/jonwhelan/following{/other_user}","gists_url":"https://api.github.com/users/jonwhelan/gists{/gist_id}","starred_url":"https://api.github.com/users/jonwhelan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jonwhelan/subscriptions","organizations_url":"https://api.github.com/users/jonwhelan/orgs","repos_url":"https://api.github.com/users/jonwhelan/repos","events_url":"https://api.github.com/users/jonwhelan/events{/privacy}","received_events_url":"https://api.github.com/users/jonwhelan/received_events","type":"User","site_admin":false},"created_at":"2018-10-27T23:01:52Z","updated_at":"2018-10-27T23:01:52Z","author_association":"NONE","body":"Thanks for getting back quickly with an explanation! I played around with it some more after submitting the issue to come up with a more accurate example of my setup. Just posting this for sake of discussion should anyone run across this.\r\n\r\n```js\r\nconst chainedFuture = Future((rej, res) => {\r\n\t\tsetTimeout(() => res('test'), 100);\r\n\t\treturn () => {\r\n\t\t\tconsole.log(`cancelling 1`);\r\n\t\t};\r\n\t}).chain((val) =>\r\n\t\tFuture((rej, res) => {\r\n\t\t\treturn () => {\r\n\t\t\t\t// This doesn't get called\r\n\t\t\t\tconsole.log(`cancelling 2`);\r\n\t\t\t};\r\n\t\t})\r\n\t);\r\n\r\nFuture.parallel(Infinity, [\r\n\tchainedFuture,\r\n\tFuture.rejectAfter(1, new Error()),\r\n]).fork(console.error, console.log);\r\n```\r\n\r\nIn this one, the `chainedFuture` is before the rejected future in the array so the \"issue\" doesn't necessarily depend on the order of the futures in the array. What made this behavior unexpected for me was that I thought `chainedFuture` would be handled as one \"whole\" future and thus both would run and be cancelled, but it makes sense that only the first future runs and is then cancelled before the second future is able to be forked.\r\n"}}
{"actor":{"display_login":"jonwhelan"}}