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

Error: cannot connect to Postgres. Details: Cannot read properties of undefined (reading 'setTypeParser') #7974

Open
yayashn opened this issue Aug 29, 2024 · 24 comments
Assignees
Labels
db: vercel-postgres @payloadcms/db-vercel-postgres dependency-issue The issue is in a dependency of payload - not payload itself stale status: needs-triage Possible bug which hasn't been reproduced yet

Comments

@yayashn
Copy link

yayashn commented Aug 29, 2024

Link to reproduction

No response

Environment Info

> payload-catalyst@1.0.0 payload /Users/y/Desktop/payload-catalyst
> cross-env NODE_OPTIONS=--no-deprecation payload "info"


Binaries:
  Node: 20.12.1
  npm: 10.5.0
  Yarn: N/A
  pnpm: 8.14.2
Relevant Packages:
  payload: 3.0.0-beta.96
  next: 15.0.0-canary.104
  @payloadcms/email-nodemailer: 3.0.0-beta.96
  @payloadcms/graphql: 3.0.0-beta.96
  @payloadcms/next/utilities: 3.0.0-beta.96
  @payloadcms/plugin-cloud: 3.0.0-beta.96
  @payloadcms/richtext-lexical: 3.0.0-beta.96
  @payloadcms/translations: 3.0.0-beta.96
  @payloadcms/ui/shared: 3.0.0-beta.96
  react: 19.0.0-rc-06d0b89e-20240801
  react-dom: 19.0.0-rc-06d0b89e-20240801
Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 23.1.0: Mon Oct  9 21:32:11 PDT 2023; root:xnu-10002.41.9~7/RELEASE_ARM64_T6030
  Available memory (MB): 36864
  Available CPU cores: 12

Describe the Bug

Get this error upon starting a blank project with vercel postgres:

[23:37:03] ERROR: Error: cannot connect to Postgres. Details: Cannot read properties of undefined (reading 'setTypeParser')

Reproduction Steps

-> pnpm create-payload-app@beta
-> Choose blank project
-> Enter vercel postgres database uri
-> pnpm dev

Also I think the .env doesn't automatically update with the url given to the CLI tool - though the issue persists even when I manually update the env variable.

Adapters and Plugins

db-vercel-postgres

@yayashn yayashn added status: needs-triage Possible bug which hasn't been reproduced yet v3 labels Aug 29, 2024
@gjohnsx
Copy link

gjohnsx commented Aug 30, 2024

i'm also getting this error.

i chose vercel postgres with npx create-payload-app@beta but then in vercel storage i chose the supabase integration lol. not sure if that matters but the supabase connector is new in vercel postgres.

@xfloor
Copy link
Contributor

xfloor commented Aug 31, 2024

i'm getting the same error, looks like something wrong with db-vercel-postgres adapter.
postgres with local db works fine.

@denolfe denolfe self-assigned this Sep 1, 2024
@github-actions github-actions bot removed the status: needs-triage Possible bug which hasn't been reproduced yet label Sep 1, 2024
@denolfe denolfe added the db: vercel-postgres @payloadcms/db-vercel-postgres label Sep 1, 2024
@calebfoster
Copy link

calebfoster commented Sep 2, 2024

try manually adding pg to your package file. seems like there's an issue when trying to import types from pg library.

yarn add pg

@yayashn
Copy link
Author

yayashn commented Sep 2, 2024

try manually adding pg to your package file. seems like there's an issue when trying to import types from pg library.

yarn add pg

This removes the error but now I get stuck on Pulling schema from database.... This is probably for another issue though

 ⨯ ErrorEvent {
  digest: '3527995339',
  [Symbol(kTarget)]: WebSocket {
    _events: [Object: null prototype] {
      error: [Function],
      message: [Function],
      close: [Function],
      open: [Function]
    },
    _eventsCount: 4,
    _maxListeners: undefined,
    _binaryType: 'arraybuffer',
    _closeCode: 1006,
    _closeFrameReceived: false,
    _closeFrameSent: false,
    _closeMessage: <Buffer >,
    _closeTimer: null,
    _errorEmitted: true,
    _extensions: {},
    _paused: false,
    _protocol: '',
    _readyState: 3,
    _receiver: null,
    _sender: null,
    _socket: null,
    _bufferedAmount: 0,
    _isServer: false,
    _redirects: 0,
    _autoPong: true,
    _url: 'wss://localhost/v2',
    _req: null,
    [Symbol(shapeMode)]: false,
    [Symbol(kCapture)]: false
  },
  [Symbol(kType)]: 'error',
  [Symbol(kError)]: AggregateError [ECONNREFUSED]:
      at internalConnectMultiple (node:net:1116:18)
      at afterConnectMultiple (node:net:1683:7)
      at TCPConnectWrap.callbackTrampoline (node:internal/async_hooks:130:17) {
    code: 'ECONNREFUSED',
    [errors]: [ [Error], [Error] ]
  },
  [Symbol(kMessage)]: ''
}

@denolfe
Copy link
Member

denolfe commented Sep 2, 2024

try manually adding pg to your package file. seems like there's an issue when trying to import types from pg library.

yarn add pg

I'm not sure why this would help considering pg is not a dependency of the db-vercel-postgres package.

Looking into the actual issue, though

@denolfe
Copy link
Member

denolfe commented Sep 2, 2024

Looks like there was an old drizzle issue here: drizzle-team/drizzle-orm#505

However, it looks like that should have been merged in and fixed.

@t0m3t0m3
Copy link

t0m3t0m3 commented Sep 4, 2024

I have the same error testing Payload 3.0 with vercel postgres 😔

@denolfe
Copy link
Member

denolfe commented Sep 4, 2024

I have reached out to Drizzle regarding this.

@christianalares
Copy link

Same error here. Does any one know if there is a workaround while the issue is being looked at?

@t0m3t0m3
Copy link

t0m3t0m3 commented Sep 7, 2024

Using this "deploy to vercel" button worked for me 👌😎
https://github.com/payloadcms/vercel-deploy-payload-postgres

@christianalares
Copy link

Using this "deploy to vercel" button worked for me 👌😎 https://github.com/payloadcms/vercel-deploy-payload-postgres

That template seems to use the postgresAdapter and not the vercelPostgresAdapter. I haven't dug into the code so I have no idea what it is since postgres is postgres. I don't understand why you would need another database adapter only because the postgres db is hosted on vercel but I'm sure they have a reason

@denolfe
Copy link
Member

denolfe commented Sep 10, 2024

Same error here. Does any one know if there is a workaround while the issue is being looked at?

The postgres adapter still works on vercel, it's just not as lightweight because it has pg as a dependency.

@calebfoster
Copy link

Same error here. Does any one know if there is a workaround while the issue is being looked at?

yarn add pg

should fix it for the time being. i can't remember which library when i was debugging, but maybe it was drizzle that's looking for an import from pg but is undefined until i explicitly added the dependency.

@denolfe
Copy link
Member

denolfe commented Sep 10, 2024

@calebfoster Correct, we've reached out to them in regards to this.

@denolfe denolfe added dependencies Pull requests that update a dependency file dependency-issue The issue is in a dependency of payload - not payload itself and removed dependencies Pull requests that update a dependency file labels Sep 10, 2024
@BedroomDev
Copy link

try manually adding pg to your package file. seems like there's an issue when trying to import types from pg library.
yarn add pg

This removes the error but now I get stuck on Pulling schema from database.... This is probably for another issue though

 ⨯ ErrorEvent {
  digest: '3527995339',
  [Symbol(kTarget)]: WebSocket {
    _events: [Object: null prototype] {
      error: [Function],
      message: [Function],
      close: [Function],
      open: [Function]
    },
    _eventsCount: 4,
    _maxListeners: undefined,
    _binaryType: 'arraybuffer',
    _closeCode: 1006,
    _closeFrameReceived: false,
    _closeFrameSent: false,
    _closeMessage: <Buffer >,
    _closeTimer: null,
    _errorEmitted: true,
    _extensions: {},
    _paused: false,
    _protocol: '',
    _readyState: 3,
    _receiver: null,
    _sender: null,
    _socket: null,
    _bufferedAmount: 0,
    _isServer: false,
    _redirects: 0,
    _autoPong: true,
    _url: 'wss://localhost/v2',
    _req: null,
    [Symbol(shapeMode)]: false,
    [Symbol(kCapture)]: false
  },
  [Symbol(kType)]: 'error',
  [Symbol(kError)]: AggregateError [ECONNREFUSED]:
      at internalConnectMultiple (node:net:1116:18)
      at afterConnectMultiple (node:net:1683:7)
      at TCPConnectWrap.callbackTrampoline (node:internal/async_hooks:130:17) {
    code: 'ECONNREFUSED',
    [errors]: [ [Error], [Error] ]
  },
  [Symbol(kMessage)]: ''
}

Did you fix this in any way? Got the setTypeParser error first, after installing "pg" im stuck at your error also

@judygab
Copy link

judygab commented Sep 16, 2024

also having the same error, can't run the app at all because of it

@artem-tarasenko
Copy link

Faced the same error, subscribing to this thread

@mocon
Copy link

mocon commented Sep 17, 2024

Same error here as well.

@christianstamati
Copy link

I also have the same issue

@marvinengelmann
Copy link

What's the purpose of this adapter anyway, hasn't been working once since creation, just use @payloadcms/db-postgres and everything is fine.

@AlvSovereign
Copy link

Any movement with this?

@denolfe denolfe removed the v3 label Nov 19, 2024
Copy link
Contributor

This issue has been marked as stale due to lack of activity.

To keep this issue open, please indicate that it is still relevant in a comment below.

@github-actions github-actions bot added the stale label Dec 13, 2024
Copy link
Contributor

This issue was automatically closed due to lack of activity.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Dec 21, 2024
@denolfe denolfe reopened this Dec 21, 2024
@github-actions github-actions bot added the status: needs-triage Possible bug which hasn't been reproduced yet label Dec 21, 2024
@zacuke
Copy link

zacuke commented Jan 9, 2025

Hello, I've stumbled in here upon trying Payload CMS for the first time.

First I ran:

npx create-payload-app@latest

I ensured my .ENV had a valid DATABASE_URI, but the Postgres error persists.

[22:36:34] ERROR: Error: cannot connect to Postgres. Details: read ECONNRESET

So I ran:

yarn add pg

Then I got an error about sharp, and it tells me to run this command:

npm install --platform=win32 --arch=x64 sharp

Finally, payload CMS seems to boot correctly, the database is created, and I'm off to the races playing around. Thanks for this pretty cool CMS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
db: vercel-postgres @payloadcms/db-vercel-postgres dependency-issue The issue is in a dependency of payload - not payload itself stale status: needs-triage Possible bug which hasn't been reproduced yet
Projects
None yet
Development

No branches or pull requests