I've been working with Node for about 3 years, but what is happening to me right now is driving me crazy.
My project uses Sequelize for the last 6 months and it's all working perfectly.
If I try to update the myModelObject instance with the following code, it works as expected.(I've change the real code in order to show the behavior in a more cleaner way)
...
.then(parameters => {
myModelObject.update({parameters}, { where: { id: myObjectId }})
.then(() => {
console.log("Sequelize update resolved !")
})
})
.then( () => {
console.log("Promise resolved !")
})
This will make my myModelObject updated in the DB and the console will display:
Promise resolved !
1 second later...
Sequelize update resolved !
But, the strange behavior happens when I add a return before the update of myModelObject:
...
.then(parameters => {
return myModelObject.update({parameters}, { where: { id: myObjectId }})
.then(() => {
console.log("Sequelize update resolved !")
})
})
.then( () => {
console.log("Promise resolved !")
})
This makes my code to hung.. the update is never done and a timeout happens. What I mean is that the Sequelize update is never resolved if I want to return it ! All my other Sequelize code is working perfectly !
Any hep will be very appreciate it :)
Node: 12.16.0 || Sequelize: 5.21.6 || pg: 7.18.2