Seeing "This step was still trying to run code when the step ended" error when running MySQL query

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

Jared Ledbetter : MySQL is not taking any action. Any insight on this? I’ve checked the async functions and have tried adding the await option to each function individually, but can’t seem to locate the correct one.

Console.log

This step was still trying to run code when the step ended. Make sure you promisify callback functions and await all Promises. (Reason: Socket, Learn more: https://pipedream.com/docs/workflows/steps/code/async)

No return values or exportsfor this step

Dylan Sather (Pipedream) : Hi , is this the same workflow you were working on yesterday? If not, would you mind sharing it with dylan@pipedream.com?

Jared Ledbetter : Yes it’s the same. Shared again.

Dylan Sather (Pipedream) : right now, you’re executing the query inside of a callback function, which isn’t supported on Pipedream. You may have seen the doc included in that warning - Running asynchronous code - which tells you a bit more information about this, and how to modify your code accordingly.

This is the primary reason the code we use in the MySQL test request uses the mysql2/promise package - that library supports Promises, which allows you to run code like this:

const connection = await mysql.createConnection({
  host,
  port,
  user: username,
  password,
  database,
});

const [rows, fields] = await connection.execute('SELECT NOW()');

Do you think you can modify your code to use mysql2/promise? Take a look at these docs for more information.

Jared Ledbetter : I did use it and it wasn’t working which is why I switched. I can try again.

Jared Ledbetter : I’m still getting the same error.

Dylan Sather (Pipedream) : Can you check your database to confirm the INSERT didn’t actually go through? This warning can be a false positive, so I’d like to see if the record actually appeared in your database.

You can also add a console.log(rows) statement at the end of your code step to print the results of the query.

Jared Ledbetter : I’ll check

Jared Ledbetter : The data is in the DB.

Jared Ledbetter : Now comes the fun part. Setting up the data variations.

Dylan Sather (Pipedream) : great glad the data ended up in the DB