Skip to content

Commit

Permalink
fix(idle): Do not clear preCheck from other command
Browse files Browse the repository at this point in the history
  • Loading branch information
andris9 committed May 7, 2024
1 parent bef4608 commit cdf7643
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/commands/idle.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ async function runIdle(connection) {
}
};

connection.preCheck = () => {
let connectionPreCheck = () => {
let handler = new Promise((resolve, reject) => {
preCheckWaitQueue.push({ resolve, reject });
});
Expand All @@ -57,9 +57,11 @@ async function runIdle(connection) {
return handler;
};

connection.preCheck = connectionPreCheck;

response = await connection.exec('IDLE', false, {
onPlusTag: async () => {
connection.log.debug({ msg: `Initiated IDLE, waiting for server input`, doneRequested });
connection.log.debug({ msg: `Initiated IDLE, waiting for server input`, lockId: connection.currentLock?.lockId, doneRequested });
canEnd = true;
if (doneRequested) {
preCheck();
Expand All @@ -70,8 +72,8 @@ async function runIdle(connection) {
}
});

// unset before response.next()
if (typeof connection.preCheck === 'function') {
// unset before response.next() if preCheck function is not already cleared (usually is)
if (typeof connection.preCheck === 'function' && connection.preCheck === connectionPreCheck) {
connection.log.trace({
msg: 'Clearing pre-check function',
lockId: connection.currentLock?.lockId,
Expand Down

0 comments on commit cdf7643

Please sign in to comment.