Bug Description
When SessionControlClient.close() is called (e.g., due to a connection drop), callbacks for items in midQueue are properly rejected with an error. However, the currently active MID (midInProcess) is silently set to null without invoking its callback.
This causes the pending Promise/callback to hang forever, leading to memory leaks and application freezes in production environments with unreliable network connections.
Steps to Reproduce
- Connect to a controller
- Send a command (e.g.,
request("readTimeUpload"))
- While the command is in-flight (waiting for response), the connection drops
close() is called (either manually or via the stream.on("close") handler)
- The callback/Promise from step 2 never resolves or rejects
Expected Behavior
The midInProcess callback should be rejected with the close error (or a default "service unavailable" error), consistent with how midQueue items are handled.
Relevant Code
src/sessionControlClient.js, close() method (line 432):
// midQueue items are properly rejected (lines 425-430)
if (this.midQueue && this.midQueue.length > 0) {
let e = new Error("service unavailable");
this.midQueue.forEach(item => {
process.nextTick(() => item.doCallback(e));
});
}
// But midInProcess is silently dropped
this.midInProcess = null; // <-- callback never invoked
Environment
- node-open-protocol version: 1.1.1
- Node.js version: v20.x
Bug Description
When
SessionControlClient.close()is called (e.g., due to a connection drop), callbacks for items inmidQueueare properly rejected with an error. However, the currently active MID (midInProcess) is silently set tonullwithout invoking its callback.This causes the pending Promise/callback to hang forever, leading to memory leaks and application freezes in production environments with unreliable network connections.
Steps to Reproduce
request("readTimeUpload"))close()is called (either manually or via thestream.on("close")handler)Expected Behavior
The
midInProcesscallback should be rejected with the close error (or a default "service unavailable" error), consistent with howmidQueueitems are handled.Relevant Code
src/sessionControlClient.js,close()method (line 432):Environment