petkaantonov / bluebird

:bird: :zap: Bluebird is a full featured promise library with unmatched performance.
http://bluebirdjs.com
MIT License
20.45k stars 2.34k forks source link

Disconnected promise chains for cancellation #1650

Open jmwilkinson opened 4 years ago

jmwilkinson commented 4 years ago

Please answer the questions the best you can:

1) What version of bluebird is the issue happening on?

3.7.2

2) What platform and version? (For example Node.js 0.12 or Google Chrome 32)

Node.js 10.x

3) Did this issue happen with earlier version of bluebird?

Unknown

(Write description of your issue here, stack traces from errors and code that reproduces the issue are helpful)

The docs on cancellation state:

As an optimization, the cancellation signal propagates upwards the promise chain so that an ongoing operation e.g. network request can be aborted.

There seems to be no way to prevent the propagation- that is, if a child promise is cancelled, there is no way for the parent calling promise to continue.

This can be restrictive.

Perhaps there could be a function added like noCancelPropagation() that would cause only the initial promise to be cancelled.

spion commented 4 years ago

You can create and keep a second fork of that promise (using then) and the cancellation should be unable to propagate past that point unless the fork also cancels