Skip to content

fix: reconnect when CAS released under KEEP_CONNECTION=AUTO - #16

Merged
yeongseon merged 2 commits into
cubrid-lab:mainfrom
paikend:fix/cas-reconnect-on-inactive
Jul 26, 2026
Merged

fix: reconnect when CAS released under KEEP_CONNECTION=AUTO#16
yeongseon merged 2 commits into
cubrid-lab:mainfrom
paikend:fix/cas-reconnect-on-inactive

Conversation

@paikend

@paikend paikend commented Mar 26, 2026

Copy link
Copy Markdown
Member

Summary

  • Add checkReconnect() that inspects CAS_INFO[0] status before each request and transparently reconnects when the broker has released the CAS process (KEEP_CONNECTION=AUTO, the default)
  • Call checkReconnect() from sendAndRecv() so reconnection is invisible to callers
  • Add no-op socket error handler after connect to prevent uncaught EPIPE/ECONNRESET crashes

Root Cause

The CUBRID broker may release the CAS process after a transaction commit when KEEP_CONNECTION=AUTO. This sets CAS_INFO[0] to INACTIVE (0). Subsequent requests on the dead socket cause EPIPE / ECONNRESET.

Approach

Ported the same reconnection pattern used by the official CUBRID JDBC driver (UClientSideConnection.checkReconnect()). The Python driver (pycubrid) was fixed with the same pattern in cubrid-lab/pycubrid#24.

Test plan

  • 01_connect — basic connection works
  • 02_crud — DDL → commit → DML sequence (the failing scenario) now passes
  • 03_transactions — commit/rollback cycles work

Closes #15

🤖 Generated with Claude Code

…cubrid-lab#15)

The CUBRID broker may release the CAS process after a transaction commit
when KEEP_CONNECTION=AUTO (the default). This sets CAS_INFO[0] to INACTIVE.
Subsequent requests on the dead socket cause EPIPE / ECONNRESET.

Port the same reconnection pattern used by the official JDBC driver
(UClientSideConnection.checkReconnect):

- Add checkReconnect() that inspects CAS_INFO status before each request
- Call it from sendAndRecv() so reconnection is transparent to callers
- Add no-op socket error handler to prevent uncaught EPIPE crashes

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@paikend

paikend commented Mar 28, 2026

Copy link
Copy Markdown
Member Author

I just reproduced the EPIPE bug on the current main branch (Node.js v25.2.1, CUBRID 11.2 Docker):

1. Executing query...
2. Query result: 2
3. Closing client...
Error: This socket has been ended by the other party
    at Socket.writeAfterFIN [as write] (node:net:575:14)
    code: 'EPIPE'

For reference, the same pattern was already fixed and merged in pycubrid (cubrid-lab/pycubrid#24), and I verified it works correctly there — both basic query+close and DDL scenarios pass without errors.

This PR applies the same reconnection approach. Would be great to get this merged so #15 can be closed.

@yeongseon
yeongseon merged commit 7d8406e into cubrid-lab:main Jul 26, 2026
2 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: socket EPIPE error on client.close() after query

2 participants