Prince_SaaS Prince_SaaS - 1 year ago 38
Node.js Question

Promise reject paused with an exception yet no error is log

Below is a Nodejs piece of code. I'm querying a Mongodb using mongoose. This piece of code gets paused at "Line A" with message "Paused on Exception". console shows no errors. Meanwhile this seem to happen only when I run in VS Code. Running the app from console raises no exception.

I'm inclined to say this a VS Code issue. Has anyone seen/faced same or something similar?

Board.findOne({ boardId: id }, function (err, data) {
if (!err) {
data ? resolve(data.children) : reject(data); //Line A
// line above pauses execution with this message: "Paused on Exception"
// No error logged in console. And this seem to happen only in VS code.


Mongoose already supports promises, so you can rewrite your code to this:

return Board.findOne({ boardId: id }).then(function(data) {
  if (! data) throw new Error('data empty');
  return data.children;
}).catch(function(err) {

Perhaps this also solves your VS Code issue.