You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using @neondatabase/serverless (which extends pgClient and Pool) I encountered the following fatal error thrown within pg-pool:
TypeError: Cannot set property message of #<_ErrorEvent> which has only a getter
This occurs since the exception passed to the connection callback for Pool is of type ErrorEvent (from the Cloudflare Workers websocket implementation) instead of Error, and ErrorEventhas a readonly message property that can't be overwritten.
While a fix could be written into @neondatabase/serverless to only pass an Error as pg-pool currently expects, it seemed more useful to address this here in pg-pool to be tolerant of different types for the exception in general, while preserving the original error message instead of overwriting it as per the current implementation.
Here is the diff that solved my problem:
diff --git a/node_modules/pg-pool/index.js b/node_modules/pg-pool/index.js
index 94004e0..52c595a 100644
--- a/node_modules/pg-pool/index.js+++ b/node_modules/pg-pool/index.js@@ -244,7 +244,7 @@ class Pool extends EventEmitter {
// remove the dead client from our list of clients
this._clients = this._clients.filter((c) => c !== client)
if (timeoutHit) {
- err.message = 'Connection terminated due to connection timeout'+ err = new Error('Connection terminated due to connection timeout', { cause: err });
}
// this client won’t be released, so move on immediately
andyjy
changed the title
Fatal error TypeError: Cannot set property message of #<_ErrorEvent> which has only a getter on connection timeout with @neondatabase/serverless libraryTypeError: Cannot set property message of #<_ErrorEvent> which has only a getter on connection timeout with @neondatabase/serverless library
Feb 10, 2025
Using
@neondatabase/serverless
(which extendspg
Client
andPool
) I encountered the following fatal error thrown withinpg-pool
:TypeError: Cannot set property message of #<_ErrorEvent> which has only a getter
This occurs since the exception passed to the connection callback for Pool is of type
ErrorEvent
(from the Cloudflare Workers websocket implementation) instead ofError
, andErrorEvent
has a readonly message property that can't be overwritten.While a fix could be written into @neondatabase/serverless to only pass an
Error
aspg-pool
currently expects, it seemed more useful to address this here inpg-pool
to be tolerant of different types for the exception in general, while preserving the original error message instead of overwriting it as per the current implementation.Here is the diff that solved my problem:
This issue body was partially generated by patch-package.
The text was updated successfully, but these errors were encountered: