Skip to content

Commit af8bc38

Browse files
committed
Avoid multiple listening instances
1 parent e8e3b38 commit af8bc38

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

postgresql.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,8 @@ module.exports = function (RED) {
152152
};
153153
updateStatus(0, false);
154154

155+
let client = null;
156+
155157
node.on('input', async (msg, send, done) => {
156158
// 'send' and 'done' require Node-RED 1.0+
157159
send = send || function () { node.send.apply(node, arguments); };
@@ -171,8 +173,6 @@ module.exports = function (RED) {
171173
const partsId = Math.random();
172174
let query = msg.query ? msg.query : Mustache.render(node.query, { msg });
173175

174-
let client = null;
175-
176176
const handleDone = async (isError = false) => {
177177
if (cursor) {
178178
cursor.close();
@@ -212,7 +212,10 @@ module.exports = function (RED) {
212212
}
213213
};
214214

215-
handleDone();
215+
if (node.listen) {
216+
// Avoid multiple listening instances
217+
handleDone();
218+
}
216219
updateStatus(+1);
217220
downstreamReady = true;
218221

0 commit comments

Comments
 (0)