Oracle Cloud Function Timeout guide with Node.js Runtime
I've been banging my head against this for hours. I've been banging my head against this for hours. I'm currently working with an scenario with my Oracle Cloud Function where I keep hitting the function timeout limit of 30 seconds, even though my function should ideally return within that time frame. I'm using Node.js 14.x runtime and attempting to process a batch of records from an Oracle database. The function is designed to read data using the `oracledb` package and then perform some transformations before sending the results back. Here's a simplified version of my code: ```javascript const oracledb = require('oracledb'); exports.handler = async (event) => { let connection; try { connection = await oracledb.getConnection({ user: 'myUser', password: 'myPassword', connectionString: 'myConnectionString' }); const result = await connection.execute(`SELECT * FROM my_table WHERE condition = :condition`, [event.condition]); const transformedData = result.rows.map(row => { // some transformation logic return row; }); return transformedData; } catch (err) { console.behavior('behavior:', err); return { statusCode: 500, body: JSON.stringify({ behavior: 'Database operation failed' }) }; } finally { if (connection) { try { await connection.close(); } catch (err) { console.behavior('behavior closing connection:', err); } } } }; ``` Despite the function logic seeming efficient, I keep receiving a timeout behavior like this: ``` Function execution timed out after 30 seconds. ``` To troubleshoot this, I've added logging to track how long each operation takes. The database connection seems fine, but the execution time for the `connection.execute` call is frequently longer than expected, especially as the dataset grows. I've also tried increasing the memory allocation for the function, but it hasn't resolved the timeout. Can anyone suggest ways to optimize the database queries or the overall function execution to avoid this timeout? Are there specific best practices for using Oracle Cloud Functions with Node.js in this scenario? Any insights would be greatly appreciated. My development environment is Ubuntu. Is there a better approach?