Skip to content

Commit

Permalink
Remove unecessary conditions to clearTimeout
Browse files Browse the repository at this point in the history
  • Loading branch information
sonnyp committed Jan 8, 2025
1 parent 6fa3127 commit 710b167
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions packages/stream-management/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ export default function streamManagement({
max: null,
timeout: 60_000,
_teardown: () => {
if (timeoutTimeout) clearTimeout(timeoutTimeout);
if (requestAckTimeout) clearTimeout(requestAckTimeout);
clearTimeout(timeoutTimeout);
clearTimeout(requestAckTimeout);
},
});

Expand Down Expand Up @@ -120,7 +120,7 @@ export default function streamManagement({

middleware.use((context, next) => {
const { stanza } = context;
if (timeoutTimeout) clearTimeout(timeoutTimeout);
clearTimeout(timeoutTimeout);
if (["presence", "message", "iq"].includes(stanza.name)) {
sm.inbound += 1;
} else if (stanza.is("r", NS)) {
Expand All @@ -147,7 +147,7 @@ export default function streamManagement({
}

function requestAck() {
if (timeoutTimeout) clearTimeout(timeoutTimeout);
clearTimeout(timeoutTimeout);
if (sm.timeout) {
timeoutTimeout = setTimeout(() => entity.disconnect(), sm.timeout);
}
Expand All @@ -174,7 +174,7 @@ export default function streamManagement({
}
sm.outbound_q.push(qStanza);
// Debounce requests so we send only one after a big run of stanza together
if (requestAckTimeout) clearTimeout(requestAckTimeout);
clearTimeout(requestAckTimeout);
requestAckTimeout = setTimeout(requestAck, 100);
}
return next();
Expand Down

0 comments on commit 710b167

Please sign in to comment.