g1zmo
g1zmo
CDCloudflare Developers
Created by g1zmo on 11/24/2023 in #workers-help
Cloudflare Workers + Digital Ocean Managed Postgres DB
Hello, im trying to setup a simple JS POC using Cloudflare workers. tl;dr the worker will query a Postgres DB on Digital Ocean. And i can not make it work at all. I have tried both pg and postgres javascript libraries node_compat is set to true
import { Client } from "pg";

const client = new Client({
connectionString: "postgresql://u:p@host:p/name",
ssl: {
cert: `a redacted cert`,
},
});

export default {
async fetch(
request,
env,
ctx
) {

await client.connect();

const resp = Response.json(/**some response */);
// Close the database connection, but don't block returning the response
ctx.waitUntil(client.end());
return resp;
},
};
import { Client } from "pg";

const client = new Client({
connectionString: "postgresql://u:p@host:p/name",
ssl: {
cert: `a redacted cert`,
},
});

export default {
async fetch(
request,
env,
ctx
) {

await client.connect();

const resp = Response.json(/**some response */);
// Close the database connection, but don't block returning the response
ctx.waitUntil(client.end());
return resp;
},
};
Just running client.connect here will make the worker freak out running when making a request to the endpoint. ( Starting the worker with wrangler deploy src/index.js ) Errors out with
Error
Connection terminated unexpectedly
Error
Connection terminated unexpectedly
I have tested everything ™️ . Not sure what im doing wrong. Anyone have any insight or guidance?
10 replies
CDCloudflare Developers
Created by g1zmo on 8/9/2023 in #workers-help
no_access_to_browser_worker
The Cloudflare docs states that "Workers Browser Rendering API is now in open Beta. During this period, Browser Rendering is available on all plans". But when i try to follow the getting started (https://developers.cloudflare.com/browser-rendering/get-started/screenshots/) i get the following error: workers.api.error.no_access_to_browser_worker Thank you!
3 replies