M
MastraAI2mo ago
tommy

Web Socket Connection Errors in Prod Environment

We are receiving the following error when using Drizzle to connect to Neon via a websocket: Error: All attempts to open a WebSocket to connect to the database failed. We never see this issue locally, so wondering if there is an issue with the environment.
7 Replies
Mastra Triager
Mastra Triager2mo ago
GitHub
[DISCORD:1415134574702497862] Connection Errors in Prod Environment...
This issue was created from Discord post: https://discord.com/channels/1309558646228779139/1415134574702497862 We are receiving the following error when using Drizzle to connect to Neon via a webso...
_roamin_
_roamin_2mo ago
Hi @tommy ! Could you share a small repro example? Thanks 🙏
tommy
tommyOP2mo ago
Hey @Romain , at the end of a workflow we are trying to connect to Neon using Drizzle via websockets Here is the connection in the workflow: const pool = new Pool({ connectionString: process.env.DB_URL }); Hey @Romain trying to deploy a smaller repo but running into a separate issue for that. Were you able to look into the websocket connection? @Romain There seems to be a separate issue with Monorepos that you can see more on the example that I am trying to create. @Romain I have a reproducible example that I can share with you For the websocket connection issue
_roamin_
_roamin_2mo ago
Hi @tommy ! It'd be great if you could attach it to the github issue https://github.com/mastra-ai/mastra/issues/7677 🙏
GitHub
[DISCORD:1415134574702497862] Connection Errors in Prod Environment...
This issue was created from Discord post: https://discord.com/channels/1309558646228779139/1415134574702497862 We are receiving the following error when using Drizzle to connect to Neon via a webso...
tommy
tommyOP2mo ago
@Romain I put a link to the github repo, also happy to send you the Slug of the mastra deployment if that is helpful Hey @Romain this issue is preventing us from being able to upsert information to our database after a workflow in production. Is there any ETA on a potential fix?
_roamin_
_roamin_2mo ago
Hi @tommy! It seems to be an issue with Neon. Could you try instantiating your Pool like this?
import { Pool, neonConfig } from "@neondatabase/serverless";
import { drizzle } from "drizzle-orm/neon-serverless";
import ws from 'ws';

neonConfig.webSocketConstructor = ws;

const pool = new Pool({ connectionString: process.env.DB_URL });
import { Pool, neonConfig } from "@neondatabase/serverless";
import { drizzle } from "drizzle-orm/neon-serverless";
import ws from 'ws';

neonConfig.webSocketConstructor = ws;

const pool = new Pool({ connectionString: process.env.DB_URL });
tommy
tommyOP2mo ago
We had removed that for a specific reason, but will look into work arounds.

Did you find this page helpful?