Error message: "Supabase connection is returning an undefined value

I am encountering an issue with my Vercel deployed Remix project that utilizes Supabase on the backend, Postgresql, and Prisma as the ORM. Despite setting up connection pooling and a direct connection to Supabase, I keep receiving the following error whenever I attempt to connect locally:

🔌 setting up prisma client to undefined.db.ubixifkwxkflnueueaku.supabase.co:6543
✅ app ready: http://localhost:3000
...
Error: Can't reach database server at `undefined.db.ubixifkwxkflnueueaku.supabase.co`:`6543`

Please ensure your database server is running at `undefined.db.ubixifkwxkflnueueaku.supabase.co`:`6543`.
    at startFn (C:\Users\TylerD\Desktop\dev\TheCityGomorrah\node_modules\@prisma\client\runtime\library.js:101:2598)

Additionally, when attempting to register a user in the Vercel deployment, the registration process works but does not store any data in the database. Subsequently, upon login attempts, a similar error appears in the Vercel logs:

Unhandled Promise Rejection     {"errorType":"Runtime.UnhandledPromiseRejection",...
Unknown application error occurred
Runtime.Unknown

As a result, no data is being stored in the database, preventing retrieval. The contents of my .env file include the DATABASE_URL for connection pooling and DIRECT_URL for migration updates. Despite verifying credentials and thoroughly reviewing both Prisma and Supabase documentation along with GitHub issues, the problem persists.

The Supabase logs provide the following information:

Log ID
bba2af3c-2839-40ca-be4a-44a7c54dcb2c

Log Timestamp (UTC)
2023-04-02T21:44:16.257Z

Log Event Message
C-0xaaaadd3c6810: pgbouncer/ [email protected]:56654 closing because: SASL authentication failed (age=0s)
...

Answer â„–1

It appears that your app deployment is utilizing one of the Remix template stacks. Please note that by default, the file app/db.server.ts contains specific configurations for FLY.io. (tip: you can search for the error message 🔌 setting up prisma client to to locate the file)

In particular, this section:

    if (!isLocalHost) {
      databaseUrl.host = `${FLY_REGION}.${databaseUrl.host}`

fetches the FLY_REGION environment variable, and if this variable is not set, it will result in "undefined.{database_url}", which explains the issue you are encountering.

Answer â„–2

Today, I experienced a similar issue myself. The challenge arises when configuring deployment on fly as it automatically inserts extra configuration into the app/db.server.ts file, particularly impacting the prisma client within the getClient() function.

To streamline the process and start running smoothly, my suggestion is to simply replace it with the following code snippet:

function getClient() {
  const { DATABASE_URL } = process.env;
  invariant(typeof DATABASE_URL === "string", "DATABASE_URL env var not set");
  console.log(`🔌 setting up prisma client to DATABASE_URL`);

  const client = new PrismaClient()

  // connect eagerly
  client.$connect();

  return client;
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Having trouble reaching the io object in session.socket.io

I have integrated session.socket.io into my application. o = require('socket.io').listen(tmpServer), appCookieParser = express.cookieParser(settings.cookie.secret), appRedisStore = new RedisStore(), sessionIO = new SessionSockets(io, appRedisSto ...

Fetching information from external API prior to displaying it

I am currently working on an application that is built using the React Starter Kit. Each page within the app includes a fetch function that retrieves data from an API during the componentDidMount lifecycle. My goal is to retrieve the data before renderin ...

Troubleshooting: "Application Error" when running Node app on Heroku

2020-01-28T01:42:46.028688+00:00 heroku[web.1]: Initiating process with command npm start 2020-01-28T01:42:45.000000+00:00 app[api]: Compilation completed successfully 2020-01-28T01:42:48.451589+00:00 heroku[web.1]: Transitioned from starting to cras ...

Do you find yourself obligated to execute npm install prior to using yarn?

Today's challenge is an unusual one, and I'm hoping you can provide some insight. I recently reformatted my work laptop, reinstalled all my tools, and now I'm encountering an issue where I need to run npm install before running yarn and yar ...

Executing function based on a dynamically generated string in a Node.js environment

In my project using express nodejs, I encountered a scenario while working on a specific module. I have created separate functions for different user roles and need to dynamically call the appropriate function based on the logged-in user's role. I am ...

Emphasize x-axis heading in a Highcharts graph

In my Highcharts bar graph, I am looking for a way to dynamically highlight the x-axis label of a specific bar based on an external event trigger. This event is not a standard click interaction within the Highcharts graph. Currently, I have been able to r ...

Exploring Angular Component Communication: Deciphering between @Input, @Output, and SharedService. How to Choose?

https://i.stack.imgur.com/9b3zf.pngScenario: When a node on the tree is clicked, the data contained in that node is displayed on the right. In my situation, the node represents a folder and the data consists of the devices within that folder. The node com ...

The JSON data structure is not being maintained

I am facing an issue with updating the json object model values using the code below. Even after changing the values, it seems like the model is not getting updated. I tried removing the async code and that worked. Why does the async code not work in this ...

Avoid the nesting of node_modules within node_modules

When executing npm install, specific node packages with nested node modules are installed. For example: -node_modules -packageA +js -node_modules <--- should be removed/ignored +jquery -packageA-sub1 +j ...

What's the best way to implement an NPM package in a Deno application?

I am curious about integrating the NPM package into my Deno application. Can anyone guide me on how to achieve this? ...

The mongoose Namespace does not contain an exported member called 'OptionalId'

When running npm i, I encountered an error. The error message is as follows: "../@types/mongoose/index.d.ts:191:17 - error TS2694: Namespace '"/Users/test-service/node_modules/@types/mongodb/index"' has no exported member 'OptionalId' ...

The concept of a generic type serving as a characteristic of an incoming argument

What is the best way to assign a type property of an argument to a generic in TypeScript? Here's the code snippet: const foo = <T = someObject.bar>(someObject: {[string]: any}): T => { return someObject.bar } How can we set the type of ...

React throwing a typescript error while attempting to update state based on the previous state

Hello there! I'm fairly new to working with TypeScript and I've encountered an issue with a piece of state in a child component. I'm trying to modify it based on the previous value, but every time I call the setState function, I get a type e ...

The execution of events.js failed at line 136, causing an unhandled 'error' event to be thrown

Why do I keep getting events.js:136 throw er; Unhandled 'error' event and how can I fix it? I have already tried reinstalling both nodejs and mongodb, but the error persists. package.json { "name": "bookstore", "version": "1.0.0", "description" ...

Managing access control permissions in Node.js using the Express framework

I am currently developing a node.js application using the express framework. My goal is to implement ACL permissions within this node.js and express setup. I have been experimenting with the acl package. In my server.js file, I have the following code: ...

Ensure the JSON file aligns with the TypeScript Interface

I am working with a config.json file. { "profiler": { "port": 8001, "profilerCache": { "allowedOriginsRegex": ["^http:\/\/localhost:8080$", "i"] } }, "database": { "uri": "mongodb+srv://...", "dbName": "profiler", ...

Learn how to effectively utilize templateURL in an express and angular project

Our project utilizes Express without any view engine. To set up static directories, we have the following: app.use(express.static(__dirname + '/public')); app.use(express.static(__dirname + '/view')); app.use(express.static(__dirname + ...

Looking for ways to speed up npm installation on TeamCity?

Having trouble using TeamCity to build and deploy my Ionic program. Every time, TeamCity needs to install all npm modules again. I attempted to backup the node_modules folder using PowerShell, but unfortunately TeamCity does not allow the use of remove-it ...

Repeating promises in Node.js through recursive execution

Here is a function that allows you to create a new folder on the server using xmlrpc: var createFolder = function(folder_name) { var defer = Q.defer(); client.methodCall('create_folder', [sessionID, folder_name], function(err, resp) { if ...

Exploring the possibilities of TeamCity integration with NodeJS for streamlined API testing

I'm currently in the process of setting up a CI/CD pipeline that involves using TeamCity as the build server. The pipeline has 3 build steps that I have configured: Running npm install, Executing node server.js, Running node run_tests.js The i ...