Promise.config(Object { warnings: boolean=false, longStackTraces: boolean=false, cancellation: boolean=false, monitoring: boolean=false } options) -> undefined;
Bluebird可设置长堆栈跟踪、警告、监控和取消(cancellation)。
注意:虽然这里默认值都是false
,可是在开发环境下自动会开启堆栈跟踪和警告。html
Promise.config({ // Enable warnings warnings: true, // Enable long stack traces longStackTraces: true, // Enable cancellation cancellation: true, // Enable monitoring monitoring: true });
你能够对wForgottenReturn
单独设置“检查忘记声明return”的警告:node
Promise.config({ // 开启全部警告除了“return检查” warnings: { wForgottenReturn: false } });
wForgottenReturn
是警告属性中惟一一个能够单独拆分设置的属性。跟它对应的环境变量key为BLUEBIRD_W_FORGOTTEN_RETURN
。web
在Node.js中,你能够经过环境变量对整个进程设置警告和堆栈跟踪:segmentfault
BLUEBIRD_LONG_STACK_TRACES=1 BLUEBIRD_WARNINGS=1 node app.js
若是运行时NODE_ENV
环境为development
或者BLUEBIRD_DEBUG
环境变量设置为开启的话,警告和堆栈跟踪也会被自动开启。
尽管是debug环境下,也可使用值等于0
就能主动关闭:api
# Warnings are disabled despite being in development environment NODE_ENV=development BLUEBIRD_WARNINGS=0 node app.js
若是你喜欢使用webstorm直接run,能够这样配置promise
原文连接:http://bluebirdjs.com/docs/api/promise.config.htmlapp
推荐阅读:Bluebird warning 解释说明webstorm