2017-05-31 15:28:47 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
var EXPORTED_SYMBOLS = ['Promise'];
|
|
|
|
|
|
|
|
var Promise = require('bluebird/promise')();
|
|
|
|
|
|
|
|
Promise.config({
|
|
|
|
warnings: true,
|
|
|
|
longStackTraces: true,
|
|
|
|
cancellation: true
|
|
|
|
});
|
|
|
|
|
2018-08-16 22:20:34 +00:00
|
|
|
// Use our own stub to avoid the Bluebird deprecation warnings
|
|
|
|
Promise.defer = function() {
|
|
|
|
var deferred = {};
|
|
|
|
deferred.promise = new Promise(function(resolve, reject) {
|
|
|
|
deferred.resolve = resolve;
|
|
|
|
deferred.reject = reject;
|
|
|
|
});
|
|
|
|
return deferred;
|
|
|
|
}
|
2017-05-31 15:28:47 +00:00
|
|
|
// TEMP: Only turn on if debug logging enabled?
|
|
|
|
Promise.onPossiblyUnhandledRejection((e, promise) => {
|
2022-02-21 20:45:50 +00:00
|
|
|
if (e.handledRejection) {
|
2017-05-31 15:28:47 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-06-02 14:37:14 +00:00
|
|
|
dump('Possibly unhandled rejection:\n\n'
|
2017-05-31 15:28:47 +00:00
|
|
|
+ (e.message
|
|
|
|
? e.message + "\n\n" + e.stack.split(/\n/)
|
|
|
|
// Filter out internal Bluebird calls
|
|
|
|
.filter(line => !line.includes('bluebird'))
|
|
|
|
.join('\n')
|
2017-06-02 14:37:14 +00:00
|
|
|
: e)
|
|
|
|
+ '\n');
|
2017-05-31 15:28:47 +00:00
|
|
|
throw e;
|
|
|
|
});
|
|
|
|
|
|
|
|
module.exports = Promise;
|