Cloud functions and cloudSQL error

143 views
Skip to first unread message

skr creationz

unread,
Sep 6, 2022, 1:49:05 PM9/6/22
to Google Cloud Developers
Im trying to access my CloudSQL instance from a cloud function. This is my code for the function.

exports.helloWorld = (req, res) => {

createUnixSocketPool.query(`SELECT * FROM MESSAGES`, function (error, results) {
console.log(error);
console.log(results);
res.status(200).send(results);
});
};

const mysql = require('promise-mysql');

const createUnixSocketPool = mysql.createPool({
user: <db username>,
password: <db user password>,
database: <db name>,
socketPath: '/cloudsql/<cloudSQL instance connection name>'
});


But the function will not deploy and throws an error saying that there's a bug in the user code. Someone advise.

Ernesto Contreras Pinon

unread,
Sep 7, 2022, 11:59:48 AM9/7/22
to Google Cloud Developers
The relevant error traces that are causing this message to appear can be found by first checking the function build logs, as well as the runtime logs. Can you share these logs? They would be helpful if you are still having trouble running your function.
Reply all
Reply to author
Forward
0 new messages