Cancel method in bluebird

  node.js, question

http://bluebirdjs.com/docs/api/cancellation.html

var searchPromise = Promise.resolve();  // Dummy promise to avoid null check.
 document.querySelector("#search-input").addEventListener("input", function() {
 // The handlers of the previous request must not be called
 searchPromise.cancel();
 var url = "/search?  Term= "encodeuricomponent (this.value.trim ());
 showSpinner();
 searchPromise = makeCancellableRequest(url)
 .then(function(results) {
 return transformData(results);
 })
 .then(function(transformedData) {
 document.querySelector("#search-results").innerHTML = transformedData;
 })
 .catch(function(e) {
 document.querySelector("#search-results").innerHTML = renderErrorBox(e);
 })
 .finally(function() {
 // This check is necessary because `.finally` handlers are always called.
 if (!  searchPromise.isCancelled()) {
 hideSpinner();
 bracket
 });
 });

Bluebird’s document says that after calling the cancel method, the previous requests will not be executed. I will follow the example or execute it.

var Promise = require('bluebird');
 var a = require('./a');
 var b = require('./b');
 
 var cancelPromise = Promise.resolve();
 cancelPromise.cancel();
 cancelPromise = a.fnA()
 .then(function() {
 return b.fnB();
 })
 .then(function() {
 console.log('done');
 })
 .finally(function() {
 if (cancelPromise.isCancelled()) {
 console.log('canceled');
 bracket
 console.log('end');
 });

The posture is wrong?

Config ({cancellation: true}) is turned off by default; This sentence is enough. The official documents of inside include:

.canceljs .cancel() -> undefinedCancel this promise. Will not do anything if this promise is already settled or if theCancellationfeature has not been enabled. SeeCancellationfor how to use cancellation.

Cancellation Cancellation has been redesigned for bluebird 3.x, any code that relies on 2.x cancellation semantics won’t work in 3.x. The cancellation feature isby default turned off, you can enable it usingPromise.configFull stop

demo:
clipboard.png
Result
clipboard.png