Error: cannot connect to Postgres. Details: Cannot read properties of undefined (reading 'setTypeParser')
Link to reproduction
No response
Environment Info
> [email protected] 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
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.
i'm getting the same error, looks like something wrong with db-vercel-postgres adapter. postgres with local db works fine.
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
try manually adding
pgto your package file. seems like there's an issue when trying to import types frompglibrary.
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)]: ''
}
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
Looks like there was an old drizzle issue here: https://github.com/drizzle-team/drizzle-orm/issues/505
However, it looks like that should have been merged in and fixed.
I have the same error testing Payload 3.0 with vercel postgres 😔
I have reached out to Drizzle regarding this.
Same error here. Does any one know if there is a workaround while the issue is being looked at?
Using this "deploy to vercel" button worked for me 👌😎 https://github.com/payloadcms/vercel-deploy-payload-postgres
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
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.
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.
@calebfoster Correct, we've reached out to them in regards to this.
try manually adding
pgto your package file. seems like there's an issue when trying to import types frompglibrary.yarn add pgThis 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
also having the same error, can't run the app at all because of it
Faced the same error, subscribing to this thread
Same error here as well.
I also have the same issue
What's the purpose of this adapter anyway, hasn't been working once since creation, just use @payloadcms/db-postgres and everything is fine.
Any movement with this?
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.
This issue was automatically closed due to lack of activity.
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.
I just spun up a fresh project, deployed to vercel and connected the neon database from vercel marketplace. Did not need to install any additional packages. Seems to be working so closing for now.
This issue has been automatically locked. Please open a new issue if this issue persists with any additional detail.