Cancellation architectural observations

Ron Buckton Ron.Buckton at
Wed Mar 4 19:01:40 UTC 2015

> new Promise(resolve => doLater(resolve, cts.token)).then(handleResult);
> setImmediate(() => cts.cancel());

> In this scenario cancel would be called right after the resolve method 
> is called, but before handlerResult is called. For this to work with a 
> cancellation token you would need to pass the token to every step in 
> the chain to both stop work being done and to ignore the 
> result/prevent a handler from being called. Wouldn't it be better if 
> the promise chain took care of this for the programmer?

I can be convinced that CancellationToken registrations should be invoked asynchronously, though I wonder if then CancellationTokenSource#cancel should return a Promise to observe any errors that occur. 


More information about the es-discuss mailing list