What are solutions to the "connect ETIMEDOUT" error when using mysql2/promise to manage transactions?

This topic was automatically generated from Slack. You can find the original thread here.

Hi everyone,
Can anyone help me?
I am getting “connect ETIMEDOUT” error when using mysql2/promise with the code below.
The main purpose is to manage transactions so if there is any other solution instead of mysql2/promise that is also fine.

import mysql from 'mysql2/promise';

export default defineComponent({
  props: {
    mysql: {
      type: "app",
      app: "mysql",
      description: "Connect to your MySQL database"
    }
  },
  async run({ steps, $ }) {
    let connection;
    try {
      connection = await mysql.createConnection({
        host: this.mysql.$auth.host,
        port: this.mysql.$auth.port,
        user: this.mysql.$auth.username,
        password: this.mysql.$auth.password,
        database: this.mysql.$auth.database,
        ssl: {
          rejectUnauthorized: true,
        },
      });

      await connection.beginTransaction();
      await connection.execute("INSERT INTO test (doc) VALUES (?)", ["test"]);
      await connection.execute("INSERT INTO test (doc) VALUES (?)", ["test2"]);
      await connection.execute("INSERT INTO test (doc) VALUES (?)", ["test3"]);
      await connection.commit();

    } catch (error) {
      console.error(error);
      if (connection) {
        await connection.rollback();
      }
      throw error;
    } finally {
      if (connection) {
        await connection.end();
      }
    }
  },
});

Does your MySQL DB have IP restrictions?

No, I use it normally with @pipedream/mysql in another Flow.

Could be related to the incident, are you still facing this issue?

I am still facing it both before and after the incident.

Could you please file a support ticket at Support - Pipedream and link both this workflow and the other one that’s working?