Skip to content
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

Update README.md with Neon Postgres Option #498

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

siegerts
Copy link

@siegerts siegerts commented Jan 13, 2024

Add Neon Serverless Postgres as a Postgres option for integration with Prisma.

WHY are these changes introduced?

WHAT is this pull request doing?

Checklist

Note: once this PR is merged, it becomes a new release for this template.

  • I have added/updated tests for this change
  • I have made changes to the README.md file and other related documentation, if applicable

Add Neon Serverless Postgres as a Postgres option to integration with Prisma.
@siegerts siegerts requested a review from a team as a code owner January 13, 2024 00:46
@siegerts
Copy link
Author

I have signed the CLA!

@matteodepalo
Copy link
Contributor

Hi @siegerts thank you for your PR, but unfortunately we haven't tested Neon so I'm going to close this.

@siegerts
Copy link
Author

siegerts commented Jan 16, 2024

Hi @matteodepalo! Is there a process or test suite that I can help test with? I'd be happy to work together if there's something else that's needed.

@matteodepalo
Copy link
Contributor

We could keep this open, but the reality is we would have to do some manual testing ourselves and that means it will take some time to do it. I'll re-open it but we cannot promise anything in terms of timeline unfortunately.

@matteodepalo matteodepalo reopened this Jan 19, 2024
@siegerts
Copy link
Author

Thank you! Let me know if there is anything I can do to help or support - I'd be happy to jump in.

@Nedomas
Copy link

Nedomas commented Apr 12, 2024

@siegerts I’m trying to run neon on a new Shopify app and most of the times its ok, but sometimes I randomly get this error:

MissingSessionTableError: Prisma session table does not exist. This could happen for a few reasons, see https://github.com/Shopify/shopify-app-js/tree/main/packages/shopify-app-session-storage-prisma#troubleshooting for more information
    at /var/task/build/build-nodejs-eyJydW50aW1lIjoibm9kZWpzIn0.js:41713:17
    at async PrismaSessionStorage2.loadSession (/var/task/build/build-nodejs-eyJydW50aW1lIjoibm9kZWpzIn0.js:41743:9)
    at async Object.admin (/var/task/build/build-nodejs-eyJydW50aW1lIjoibm9kZWpzIn0.js:33152:45)
    at async loader2 (/var/task/build/build-nodejs-eyJydW50aW1lIjoibm9kZWpzIn0.js:179790:38)
    at async Object.callRouteLoaderRR (/var/task/node_modules/@remix-run/server-runtime/dist/data.js:52:16)
    at async callLoaderOrAction (/var/task/node_modules/@remix-run/router/dist/router.cjs.js:4166:16)
    at async Promise.all (index 0)
    at async loadRouteData (/var/task/node_modules/@remix-run/router/dist/router.cjs.js:3638:19)
    at async queryImpl (/var/task/node_modules/@remix-run/router/dist/router.cjs.js:3481:20)
    at async Object.queryRoute (/var/task/node_modules/@remix-run/router/dist/router.cjs.js:3447:18) {
  [cause]: Error: Connection terminated unexpectedly
      at /var/task/build/build-nodejs-eyJydW50aW1lIjoibm9kZWpzIn0.js:134614:19
      at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
      at async PrismaNeon.performIO (/var/task/build/build-nodejs-eyJydW50aW1lIjoibm9kZWpzIn0.js:135796:17)
      at async PrismaNeon.queryRaw (/var/task/build/build-nodejs-eyJydW50aW1lIjoibm9kZWpzIn0.js:135766:15)
      at async /var/task/build/build-nodejs-eyJydW50aW1lIjoibm9kZWpzIn0.js:36845:18 {
    clientVersion: '5.12.1'
  }
}

(this is from vercel logs)

The error message is non-sensical as Session table definately exists. But you can see at the start of the stacktrace I get: "[cause]: Error: Connection terminated unexpectedly". I thought that maybe this happens only on Neon boot, but this happens even with always-on Neon instance.

Here’s my prisma init if useful:

import { Pool, neonConfig } from '@neondatabase/serverless'
import { PrismaNeon } from '@prisma/adapter-neon'
import { PrismaClient } from '@prisma/client'
import ws from 'ws'

declare global {
  var prisma: ReturnType<typeof prismaClientSingleton>
}

neonConfig.webSocketConstructor = ws

const prismaClientSingleton = () => {
  const connectionString = `${process.env.DATABASE_URL}`
  const pool = new Pool({ connectionString })
  const adapter = new PrismaNeon(pool)

  return new PrismaClient({ adapter })
}

export const prisma = globalThis.prisma ?? prismaClientSingleton()

if (process.env.NODE_ENV !== 'production') globalThis.prisma = prisma

(I also use the neon -pooler)

Any ideas on why this might happen?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants