prints the error mentioned in the title, "(node:5540) Warning: a promise was created in a handler but was not returned from it". I have tried changing and tweaking the code but the error still persists.

This warning is because your code is creating promises inside of .then() handlers, but not returning them from those handlers.

Change:

User.create(user)

to:

return User.create(user)

And, change:

Store.create(store)

to

return Store.create(store)

When you don't return these promises that are created inside .then() handlers, they become separate, independent promise chains and are not linked to the previous promise chain. This is usually a programming mistake which is why Bluebird makes it a warning.

When you return them, then they add to the promise chain and thus the parent promise waits for their completion before continuing on with the chain.

I'd also suggest you probably want to change:

auth.hash(user.password)

to:

return auth.hash(user.password)

So that the caller of create() can tell when everything is done.

And, you only need one .catch() handler at the highest level. Rejected promises propagate up to the top level for you automatically (one of the things that makes error handling when using promises easier).

Email codedump link for (node:5540) Warning: a promise was created in a handler but was not returned from it