Data undefined when in production, works in local development

Hi,

I have a problem with latest Netlify serverless function deployed to Netlify. Basically, the function connects to database and executes a query. Data returned is used in Angular component. Locally it works, but in production data is not returned. I have added console.logs in client side and I see no data, so I assume that something is prevent query in the function to be executed.

This is the query:

prompts = await connection.execute(
            `SELECT sentence, emotionName FROM Sentence ORDER BY sentenceID DESC LIMIT ${page}, ${perPage};`
        );
Error: Uncaught (in promise): TypeError: Cannot read properties of undefined (reading '0') TypeError: Cannot read properties of undefined (reading '0') at https://deploy-preview-22--color-healing.netlify.app/main.4beea88f24107e7a.js:1:589897 at v.invoke (https://deploy-preview-22--color-healing.netlify.app/polyfills.7f740e70b18aea79.js:1:6588) at Object.onInvoke (https://deploy-preview-22--color-healing.netlify.app/main.4beea88f24107e7a.js:1:108631) at v.invoke (https://deploy-preview-22--color-healing.netlify.app/polyfills.7f740e70b18aea79.js:1:6528) at M.run (https://deploy-preview-22--color-healing.netlify.app/polyfills.7f740e70b18aea79.js:1:1954) at https://deploy-preview-22--color-healing.netlify.app/polyfills.7f740e70b18aea79.js:1:16798 at v.invokeTask (https://deploy-preview-22--color-healing.netlify.app/polyfills.7f740e70b18aea79.js:1:7206) at Object.onInvokeTask (https://deploy-preview-22--color-healing.netlify.app/main.4beea88f24107e7a.js:1:108447) at v.invokeTask (https://deploy-preview-22--color-healing.netlify.app/polyfills.7f740e70b18aea79.js:1:7127) at M.runTask (https://deploy-preview-22--color-healing.netlify.app/polyfills.7f740e70b18aea79.js:1:2571)

Site url: https://color-healing.netlify.app/
Site preview: Color Healing

I was never in this kind of situation, and I don’t really know how to approach debugging of Netlify function in production.

Help appreciated.

Hi, can you attach a link to your function log.

1 Like

Hi Sam,

Here is the log. I actually forgot to add the ENV variable for password. That’s why access was denied and there was no query executed.

Thank you for pointing me in the right direction.

Aug 10, 03:22:11 PM: 3cc8047d INFO   Error: Access denied for user '---' (using password: NO)
Aug 10, 03:22:11 PM: 3cc8047d INFO       at Object.createConnection (/var/task/functions/get-prompt-list/get-prompt-list.js:18602:35)
Aug 10, 03:22:11 PM: 3cc8047d INFO       at getData (/var/task/functions/get-prompt-list/get-prompt-list.js:18870:36)
Aug 10, 03:22:11 PM: 3cc8047d INFO       at Runtime.handler (/var/task/functions/get-prompt-list/get-prompt-list.js:18893:9)
Aug 10, 03:22:11 PM: 3cc8047d INFO       at Runtime.handleOnceNonStreaming (file:///var/runtime/index.mjs:1083:29) {
Aug 10, 03:22:11 PM: 3cc8047d INFO     code: 'ER_ACCESS_DENIED_ERROR',
Aug 10, 03:22:11 PM: 3cc8047d INFO     errno: 1045,
Aug 10, 03:22:11 PM: 3cc8047d INFO     sqlState: '28000'
Aug 10, 03:22:11 PM: 3cc8047d INFO   }
Aug 10, 03:22:11 PM: 3cc8047d Duration: 133.81 ms	Memory Usage: 80 MB	Init Duration: 208.34 ms