I`m getting this error while doing an request.
(node:3993) [DEP0097] DeprecationWarning: Using a domain property in MakeCallback is deprecated. Use the async_context variant of MakeCallback or the AsyncResource class instead.
That`s the code of my controller: AppointmentController The code of the queue: Queue Nodemailer: Mail
async delete(req, res) {
const { appointment_id } = req.params;
if (!appointment_id) {
return res.status(404).json({
error: "It's not possible to cancel an appointment with passing an id",
});
}
const appointment = await Appointment.findByPk(appointment_id, {
include: [
{
model: Restaurant,
as: 'restaurant',
attributes: ['id', 'name', 'provider_id'],
include: [
{
model: Provider,
foreignKey: 'provider_id',
as: 'provider',
},
],
},
{
model: User,
as: 'user',
attributes: ['id', 'name', 'email'],
},
],
});
if (!appointment) {
return res.status(404).json({ error: 'Appointment not found' });
}
if (appointment && appointment.canceled_at !== null) {
return res
.status(420)
.json({ error: 'This appointment was already canceled' });
}
// The user can cancel only his/her appointments - Verifying if the id is different
if (appointment.user_id !== req.userId) {
return res.status(401).json({
error: "You don't have permission to cancel this appointment",
});
}
// It's just allowed to cancel appointments with 1 hour of advance
const dateWithSub = subHours(appointment.date, 1);
if (isBefore(dateWithSub, new Date())) {
return res.status(401).json({
error: 'You can only cancel appointments with 1 hour of advance',
});
}
// Changing the field canceled_at with the current date
appointment.canceled_at = new Date();
await appointment.save();
const formatedDate = format(
appointment.date,
"'Day' dd 'of' MMMM',' H:mm 'Hours'"
);
await Queue.add(CancellationMail.key, { appointment, formatedDate });
return res.json(appointment);
}
}
Also, I'm using a queue for the email job. The thing is, I don't know if this error is related to node or is from one of the services that I'm using.
An easy way to find the source of that is to launch your app with the --trace-deprecation
flag, which will print a stack trace pointing to the code that uses the deprecated module.
The deprecation warning is happening due to a use of the deprecated domain module.
I don't see that your code is using it directly and so, I'm pretty sure one of the packages that you require is using it. First, I would go through your own code to ensure you are not using it and if not then make sure all of your dependencies are up to date.
If that still doesn't fix, then you need to figure out where the warning is coming from and the best way to do that would be to step through your code in a debugger and see what the stack trace is when this warning is emitted.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With