Hello,
I have a small issue with an error message I get when I mistakenly setup my NestJS / Typeorm / PG stack badly.
The error message is not informative, look:
My typeorm setup in ormconfig.json:
module.exports = {
type: "postgres",
host: "127.0.0.1",
port: 3306, // BAD! This causes an error, see the message I get, below
username: "[Redacted]",
password: "[Redacted]",
database: "[Redacted]",
entities: ["dist/entities/**/*.entity.js"],
migrations: ["dist/migrations/**/*.js"],
};
This is obviously a bad configuration (3306 being default port to mysql, not postgres, silly me)
Now, this is the error message I get:
[Redacted_local_path]/node_modules/pg/lib/connection.js:122
var eventName = msg.name === 'error' ? 'errorMessage' : msg.name
^
TypeError: Cannot read property 'name' of undefined
at Socket.<anonymous> ([Redacted_local_path]/node_modules/pg/lib/connection.js:122:27)
at Socket.emit (events.js:203:13)
at addChunk (_stream_readable.js:294:12)
at readableAddChunk (_stream_readable.js:275:11)
at Socket.Readable.push (_stream_readable.js:210:10)
at TCP.onStreamRead (internal/stream_base_commons.js:166:17)
It should read at least something like "Your configuration is bad, please check it!"
Thank you for reading, have a nice day!
I had the exact same issue. I also used port 3306. Super annoying. Hope they fix this.
Same error, does it work with a other port?
@Pleximar The default PostgreSQL port is 5432.
It should read at least something like "Your configuration is bad, please check it!"
There's no way to know if a configuration is bad before a connection failure happens. You could run postgres on any port you wanted. There's a potential to try to parse _the very first response message_ and if it fails to parse perhaps _hint_ that you might have configured it wrong...but this isn't high priority for me. If you'd like to submit a patch to do this, I'm definitely open to reviewing it & merging it.