-
Notifications
You must be signed in to change notification settings - Fork 41
midInProcess callback not invoked on close, causing promise to hang #53
Copy link
Copy link
Open
Description
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 thestream.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 invokedEnvironment
- node-open-protocol version: 1.1.1
- Node.js version: v20.x
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels