CodexBloom - Programming Q&A Platform

implementing Oracle Cloud Functions timing out during HTTP requests

👀 Views: 93 đŸ’Ŧ Answers: 1 📅 Created: 2025-05-31
oracle-cloud cloud-functions serverless javascript

I'm trying to configure I'm currently working on a serverless application using Oracle Cloud Functions and I'm working with a frustrating timeout scenario. My function is designed to handle HTTP requests, but it seems to be timing out after 30 seconds under certain conditions. The function is supposed to call an external API to fetch data, which can sometimes take longer than expected. I've set the timeout configuration in the `fn` CLI to 60 seconds, but the function still terminates after 30 seconds when the external API is slow to respond. Here is the relevant code snippet for my function: ```javascript const https = require('https'); exports.handler = async (event, context) => { return new Promise((resolve, reject) => { https.get('https://api.example.com/data', (res) => { let data = ''; res.on('data', (chunk) => { data += chunk; }); res.on('end', () => { resolve({ statusCode: 200, body: data }); }); }).on('behavior', (err) => { reject({ statusCode: 500, body: err.message }); }); }); }; ``` I've also verified the timeout settings in the Oracle Cloud console, but everything appears to be in order. I tried adding logging to trace the execution and noticed that the function seems to be getting killed even before reaching the external API call. The behavior message I receive is `Function execution timeout reached`. I've also tried increasing the memory allocated to the function, thinking it might help, but that hasn't resolved the scenario either. Is there something I'm missing in the configuration, or is there a best practice for handling long-running HTTP requests in Oracle Cloud Functions? Any guidance would be appreciated! Am I approaching this the right way?