{"action":"created","issue":{"url":"https://api.github.com/repos/nodejs/promise-use-cases/issues/10","repository_url":"https://api.github.com/repos/nodejs/promise-use-cases","labels_url":"https://api.github.com/repos/nodejs/promise-use-cases/issues/10/labels{/name}","comments_url":"https://api.github.com/repos/nodejs/promise-use-cases/issues/10/comments","events_url":"https://api.github.com/repos/nodejs/promise-use-cases/issues/10/events","html_url":"https://github.com/nodejs/promise-use-cases/issues/10","id":324696497,"node_id":"MDU6SXNzdWUzMjQ2OTY0OTc=","number":10,"title":"No standard way to cancel promises / async operations","user":{"login":"itaysabato","id":2768658,"node_id":"MDQ6VXNlcjI3Njg2NTg=","avatar_url":"https://avatars0.githubusercontent.com/u/2768658?v=4","gravatar_id":"","url":"https://api.github.com/users/itaysabato","html_url":"https://github.com/itaysabato","followers_url":"https://api.github.com/users/itaysabato/followers","following_url":"https://api.github.com/users/itaysabato/following{/other_user}","gists_url":"https://api.github.com/users/itaysabato/gists{/gist_id}","starred_url":"https://api.github.com/users/itaysabato/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/itaysabato/subscriptions","organizations_url":"https://api.github.com/users/itaysabato/orgs","repos_url":"https://api.github.com/users/itaysabato/repos","events_url":"https://api.github.com/users/itaysabato/events{/privacy}","received_events_url":"https://api.github.com/users/itaysabato/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":15,"created_at":"2018-05-20T09:41:56Z","updated_at":"2018-06-06T23:47:39Z","closed_at":"2018-05-25T12:27:05Z","author_association":"NONE","body":"And also no reasonable way to implement it in userland.\r\n\r\nFor instance, one can override native promises with [Bluebird](http://bluebirdjs.com) promises which expose an optional cancellation API, **_but_** this API does not inter-operate with modern async constructs such as async functions, generators and iterators.\r\n\r\nIMO, this (not to mention the forgoing of native promises altogether for cancellation's sake) is a price too high to pay in the long run.\r\n\r\n## Suggestion\r\n\r\nWithout forcing the community to agree on a \"right\" way to implement cancellations, _hooks_ can be provided to allow developers a way to standardize cancellations in their respective applications and in the way they see fit.\r\n\r\n[This reference implementation](https://gist.github.com/itaysabato/f78394793ae265c7895e862c2b2bd215) demonstrates a possible implementation of a \"Bluebird-style\" cancellation API on top of native promises via a promise _interception_ hooks API that I drafted therein.\r\n\r\nBoth the implementation and the suggested interception API should be considered as a _proof of concept_ that may be incomplete and possibly buggy.\r\n\r\n## Additional use cases\r\n\r\nThese kinds of interception hooks could prove useful for implementing additional use cases, e.g. for debugging tools etc.\r\n\r\nI will add these additional use cases as separate issues that will reference this one."},"comment":{"url":"https://api.github.com/repos/nodejs/promise-use-cases/issues/comments/395248471","html_url":"https://github.com/nodejs/promise-use-cases/issues/10#issuecomment-395248471","issue_url":"https://api.github.com/repos/nodejs/promise-use-cases/issues/10","id":395248471,"node_id":"MDEyOklzc3VlQ29tbWVudDM5NTI0ODQ3MQ==","user":{"login":"overlookmotel","id":557937,"node_id":"MDQ6VXNlcjU1NzkzNw==","avatar_url":"https://avatars0.githubusercontent.com/u/557937?v=4","gravatar_id":"","url":"https://api.github.com/users/overlookmotel","html_url":"https://github.com/overlookmotel","followers_url":"https://api.github.com/users/overlookmotel/followers","following_url":"https://api.github.com/users/overlookmotel/following{/other_user}","gists_url":"https://api.github.com/users/overlookmotel/gists{/gist_id}","starred_url":"https://api.github.com/users/overlookmotel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/overlookmotel/subscriptions","organizations_url":"https://api.github.com/users/overlookmotel/orgs","repos_url":"https://api.github.com/users/overlookmotel/repos","events_url":"https://api.github.com/users/overlookmotel/events{/privacy}","received_events_url":"https://api.github.com/users/overlookmotel/received_events","type":"User","site_admin":false},"created_at":"2018-06-06T23:47:39Z","updated_at":"2018-06-06T23:47:39Z","author_association":"NONE","body":"@getify You said:\r\n\r\n> This topic has been debated at length, and any mechanism which allows for a promise to be used to signal a cancelation \"back up the chain\" will be opposed by many of us for all the same reasons that have been brought up.\r\n\r\nI'd be very interested to read this debate. I have used bluebird's ability to do exactly what you are opposing and found it a much clearer and more composable interface for cancellation than tokens. But I know many people more experienced that me don't like it.\r\n\r\nCould you point me in the right direction to read more on this please?"}}
{"actor":{"display_login":"overlookmotel"}}