Method detach with transactions



I have a table of products and another of images, with a relationship of many to many. My problem starts when I want to delete a product with all of them and their relationships with the images.

I share my method to destroy.

async destroy ({ params, response }) {
    const { id } = params;
    const product = await Product.findOrFail(id);

    const transaction = await Database.beginTransaction();

    try {
      /** First I make sure to eliminate the images */
      await product.images().detach(null, transaction);

      /** After I delete the product registration */
      await product.delete();

      await transaction.commit();

      return response.status(200).send({
        message: 'Producto eliminado'
    } catch (e) {
      await transaction.rollback();

      return response.status(500).send({
        error: 'Ha ocurrido un error al eliminar el producto.',
        message: e.message

When calling the method I do not receive the client does not receive a response, it seems that somewhere has cycled or never ends. After a while I receive a request timeout.