Skip to content

Commit 138b8aa

Browse files
committed
Fix TCP reconnect after close and run connected messaging in CI
TCPLayer.sendNextMessage reconnected unconditionally whenever the state was disconnected, so any deferred wakeup arriving after close() (e.g. from the final write's callback) silently opened a fresh socket that nothing would ever close. It now reconnects only when the request queue is non-empty. Adds the OpENer connected-messaging integration test to CI. https://claude.ai/code/session_01AuAYuP6dTn8ALpkKErQuby
1 parent cfb9d24 commit 138b8aa

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ jobs:
4848
- working-directory: node-drivers
4949
run: node test/integration/eip.js
5050

51+
- working-directory: node-drivers
52+
run: node test/integration/cip-connected.js
53+
5154
- uses: actions/setup-python@v5
5255
with:
5356
python-version: '3.11'

src/layers/tcp/index.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,8 +240,11 @@ export default class TCPLayer extends Layer {
240240
});
241241
}
242242
} else if (this._connectionState === 0) {
243-
/** Reconnect */
244-
connect(this);
243+
/** Reconnect only when there is something to send, otherwise a
244+
* deferred wakeup after close() would reopen the connection */
245+
if (this.hasRequest()) {
246+
connect(this);
247+
}
245248
}
246249
}
247250

0 commit comments

Comments
 (0)