-
Notifications
You must be signed in to change notification settings - Fork 816
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: remove duplicate neon pooler #990
Conversation
Important Auto Review SkippedAuto reviews are limited to the following labels: coderabbit. Please add one of these labels to enable auto reviews. Please check the settings in the CodeRabbit UI or the To trigger a single review, invoke the Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
de nada |
scripts/vercel.sh
Outdated
PGBOUNCER_HOST="$(echo "$PGHOST" | sed "s/${PROJECT_ID}/${PROJECT_ID}-pooler/")" | ||
|
||
export NEXT_PRIVATE_DATABASE_URL="postgres://${PGUSER}:${PGPASSWORD}@${PGBOUNCER_HOST}/${PGDATABASE}?pgbouncer=true" | ||
export NEXT_PRIVATE_DATABASE_URL="postgres://${PGUSER}:${PGPASSWORD}@${PGHOST}/${PGDATABASE}?pgbouncer=true" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now we need to account for the direct database url so prisma migrations can run 🥲
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also we have a repeat of the logic in packages/prisma/helper.ts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now we need to account for the direct database url so prisma migrations can run 🥲
Apparently if we upgrade prisma to 5.10 it lets us migrate using a connection pool?
https://neon.tech/docs/guides/prisma#connection-pooling-with-prisma-migrate
Also we have a repeat of the logic in packages/prisma/helper.ts
The logic in the helper checks whether pooler is already attached, want me to try clean it up anyway?
// Support for neon.tech (Neon Database)
if (url.hostname.endsWith('neon.tech')) {
const [projectId, ...rest] = url.hostname.split('.');
if (!projectId.endsWith('-pooler')) {
url.hostname = `${projectId}-pooler.${rest.join('.')}`;
}
url.searchParams.set('pgbouncer', 'true');
process.env.NEXT_PRIVATE_DATABASE_URL = url.toString().replace('https://', 'postgres://');
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also what was the reason we can't use the direct database URL for neon for migrations?
@Mythie could you please have a look when possible
Created example PR with a migration, since this variable is only created for new branches: Not sure if this will conflict with any thing on production since this should only be for previews |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, but also too big brain for me to fully understand anymore
Description
Fixes the issue with Vercel preview deployments failing.
It appears that the old
PGHOST
environment variable injected by neon was:ep-snowy-snowflake-a2vc5pa2.eu-central-1.aws.neon.tech
It is now:
ep-snowy-snowflake-a2vc5pa2.eu-central-1-pooler.aws.neon.tech
Notice the
-pooler
being attached automatically to thePGHOST
.References
https://neon.tech/docs/changelog
https://neon.tech/docs/guides/vercel#manage-vercel-environment-variables