这是正常的bluebird / node.js / expresserror handling?

所以,我做了这个愚蠢的错字,花了我相当多的时间来find它,因为我总是从执行mongoose查询中得到一个空的错误。 我重新创build了一个更通用的行为。

var express = require('express'); var router = express.Router(); var Promise = require('Bluebird'); router.patch('/test', function (req, res, next){ var testPromise = new Promise(function (resolve, reject) { resolve(); }) .then(function(result){ if(thisIsAnExampleTypo){} res.status(200).json({ message: 'this will no be executed because of the typo', object: result }); }) .catch(function(err){ //console.log(err); return res.status(500).json({ title: 'This will execute because of the typo in the then-function', error: {message: 'but it will also crash the node.js server if I log the error before this return statement'} }); }); }); 

上面的代码不会崩溃服务器,但会执行catch函数。 如果我取消注释console.log(err); 行它会崩溃的节点服务器,这是没有意义的。 此外,它只会崩溃,如果我login错误,如果我使它console.log('test'); 它会继续运行。

我在Node.js v8.1.4,“express”:“〜4.14.0”和“bluebird”:“^ 3.5.0”。

提前感谢任何解释/build议/帮助,这对我来说已经不是什么问题了,但是这种行为真的让我感到困惑,我不知道该在哪里报告。