Skip to content

Commit 1490611

Browse files
committed
Experimental fix for AWS Lambda issue (!3636)
1 parent 7288608 commit 1490611

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

lib/dialects/postgres/index.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,22 @@ function Client_PG(config) {
2525
inherits(Client_PG, Client);
2626

2727
Object.assign(Client_PG.prototype, {
28+
validateConnection(connection) {
29+
// TODO: This is just an experimental fix.
30+
31+
const c = connection.connection;
32+
// pg has not even attempted to establish a connection yet.
33+
// Which means: pg will establish a connection upon first use.
34+
if (!c) {
35+
return true;
36+
}
37+
38+
// pg has established a connection already. Let's confirm that
39+
// it's still connected.
40+
const s = c.stream;
41+
return !s.connecting || (s.readable && s.writable);
42+
},
43+
2844
queryCompiler() {
2945
return new QueryCompiler(this, ...arguments);
3046
},
@@ -124,6 +140,7 @@ Object.assign(Client_PG.prototype, {
124140
resolver(connection);
125141
});
126142
}
143+
console.log(connection);
127144
resolver(connection);
128145
});
129146
}).then(function setSearchPath(connection) {

0 commit comments

Comments
 (0)