I have DO function like below which connect to managed PostgreSQL database and call a procedure, but function timeout when I invoke it through the control panel, I even tried increasing timeout duration and memory. (tried upto 1 min, 256MB of memory)
exports.main = async function main() {
const { Client } = require("pg");
require("dotenv").config();
console.log("Database URL:", process.env.DB_URL);
const client = new Client({
connectionString: process.env.DB_URL,
});
_try_ {
_await_ client.connect();
_await_ client.query("CALL app.prcdre()");
} _catch_ (err) {
console.error(err);
} _finally_ {
_await_ client.end();
}
};
project.yml
packages:
- name: sample
functions:
- name: dailyproc
binary: false
runtime: "nodejs:18"
main: ""
web: true
environment:
DATABASE_URL: "${DB_URL}"
limits:
timeout: 3000
memory: 128
triggers:
- name: daily-payout-10pm
sourceType: scheduler
sourceDetails:
cron: "00 22 * * *"
ENV is set properly as I can see with the console log. Also note this database is also attached to app platform.
How could I resolve this timeout?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Enter your email to get $200 in credit for your first 60 days with DigitalOcean.
New accounts only. By submitting your email you agree to our Privacy Policy.
Hi there,
It sounds like your function is deployed separately in a sandbox namespace rather than the App Platform. That would mean that the function is not part of the trusted sources of your database.
There are two workarounds here:
Let me know how it goes.
Best,
Bobby