Does anyone know why NodeJS instances crash on a Next tick or Mongoose pre error? What are some ideas to create a more stable application as we work to identify all errors? Is IBM planning more resiliency?
I guess we could just create a Linux docker image and run node from there - but that defies the point of these independent instances.
We have implemented the mongoose middelware function for brcypting the password :
userSchema.pre('save', function validate(next) {
var user = this;
if (!user.isModified('password')) return next();
bcrypt.genSalt(10, function (err, salt) {
if (err) return next(err);
bcrypt.hash(user.password, salt, null, function (err, hash) {
if (err) return next(err);
user.password = hash;
next();
// done();
});
});
});
This is controlled by the "hooks" module in nom-mongoose.
I tried to create the same error on my end and I was able to raise the same error if I don't pass any arguments to the function validate(...
This means on Bluemix, the next/done arguments used are not passed and received by the hooks module, otherwise it works fine on every machine.