timgit / pg-boss

Queueing jobs in Postgres from Node.js like a boss
MIT License
2.09k stars 158 forks source link

permission denied errors from managed db through SSL #279

Closed sundowndev closed 3 years ago

sundowndev commented 3 years ago

Hi, I've successfully implemented your lib in my app, but when deploying the feature in production, the app crashes because pg-boss doesn't manage to connect/migrate the database as expected.

ℹ Starting worker service...
This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason:
error: permission denied for database <redacted>
    at Parser.parseErrorMessage (/srv/app/node_modules/pg-boss/node_modules/pg-protocol/dist/parser.js:287:98)
    at Parser.handlePacket (/srv/app/node_modules/pg-boss/node_modules/pg-protocol/dist/parser.js:126:29)
    at Parser.parse (/srv/app/node_modules/pg-boss/node_modules/pg-protocol/dist/parser.js:39:38)
    at TLSSocket.<anonymous> (/srv/app/node_modules/pg-boss/node_modules/pg-protocol/dist/index.js:11:42)
    at TLSSocket.emit (events.js:400:28)
    at TLSSocket.emit (domain.js:475:12)
    at addChunk (internal/streams/readable.js:293:12)
    at readableAddChunk (internal/streams/readable.js:267:9)
    at TLSSocket.Readable.push (internal/streams/readable.js:206:10)
    at TLSWrap.onStreamRead (internal/stream_base_commons.js:188:23)
Done in 4.95s.

I'm using a managed Digitalocean database running on postgres 12. I don't know if it's related to SSL but it seems like there's a plan that's disallowed in the server. Any ideas?

sundowndev commented 3 years ago

It was due to missing permissions from the current user. Digitalocean requires to use the admin user to run pg-boss plans, my bad!