postgres
postgres copied to clipboard
TypeError: Attempting to change value of a readonly property.
Getting those error
error: write CONNECT_TIMEOUT xxxxx.eu-west-1.rds.amazonaws.com:5432
code: "CONNECT_TIMEOUT"
at connection (/home/bun/app/node_modules/postgres/src/errors.js:26:2)
at connectTimedOut (/home/bun/app/node_modules/postgres/src/connection.js:257:12)
at done (/home/bun/app/node_modules/postgres/src/connection.js:1035:4)
383 | query && queryError(query, err)
384 | initial && (queryError(initial, err), initial = null)
385 | }
386 |
387 | function queryError(query, err) {
388 | Object.defineProperties(err, {
^
TypeError: Attempting to change value of a readonly property.
at queryError (/home/bun/app/node_modules/postgres/src/connection.js:388:4)
at errored (/home/bun/app/node_modules/postgres/src/connection.js:384:16)
at connectTimedOut (/home/bun/app/node_modules/postgres/src/connection.js:257:4)
at done (/home/bun/app/node_modules/postgres/src/connection.js:1035:4)
Using version 3.4.3 and bun v1.0.13
The write timeout could be my app doing something wrong but I don't expect TypeError
you have a timeout there, the "Attempting to change value of a readonly property" seems like a complimentary thing on the stack trace
I know. But a timeout shouldn’t causing TypeError.
Yep, same problem. It's in the library.
TypeError: Attempting to change value of a readonly property.
at queryError (/app/node_modules/postgres/src/connection.js:388:5)
at errored (/app/node_modules/postgres/src/connection.js:384:17)
at data (/app/node_modules/postgres/src/connection.js:318:9)
at addChunk (node:stream:1940:43)
at readableAddChunk (node:stream:1894:59)
at data (node:net:52:17)
27 | return error
28 | }
29 |
30 | function postgres(x) {
31 | const error = new PostgresError(x)
32 | Error.captureStackTrace(error, postgres)
^
PostgresError: query_wait_timeout
code: "08P01"
Your problem is here:
function queryError(query, err) {
/// `err` is undefined here for some reason.
/// Should handle null/undefined case so that the error handler *itself* doesn't throw an undefined error.
/// Line 388:
Object.defineProperties(err, {
stack: { value: err.stack + query.origin.replace(/.*\n/, '\n'), enumerable: options.debug },
query: { value: query.string, enumerable: options.debug },
parameters: { value: query.parameters, enumerable: options.debug },
args: { value: query.args, enumerable: options.debug },
types: { value: query.statement && query.statement.types, enumerable: options.debug }
})
query.reject(err)
}
It works in node, so you should file an issue in bun about not being able to override properties on an Error instance.