Skip to content

Commit 8705db5

Browse files
committed
catch the exception thrown when a connection in the pool is unhealthy and the pool tries to destroy it + close the open socket. Fix for Issue #1604.
1 parent 6dfd36f commit 8705db5

File tree

2 files changed

+24
-15
lines changed

2 files changed

+24
-15
lines changed

doc/src/release_notes.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ Thin Mode Changes
2525
in embedded quotes and in JSON syntax.
2626
`Issue #1605 <https://github.com/oracle/node-oracledb/issues/1605>`__.
2727

28+
#) Fixed bug that caused an exception to be thrown unnecessarily when a connection was closed.
29+
`Issue #1604 <https://github.com/oracle/node-oracledb/issues/1604>`__.
30+
2831
Thick Mode Changes
2932
++++++++++++++++++
3033

lib/thin/connection.js

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -59,23 +59,29 @@ class ThinConnectionImpl extends ConnectionImpl {
5959
* @return {Promise}
6060
*/
6161
async close() {
62-
if (this._protocol.txnInProgress) {
63-
await this.rollback();
64-
}
65-
this._protocol.callTimeout = 0; // not applicable for close
66-
if (this._drcpEnabled) {
67-
await this._sessRelease();
68-
this._drcpEstablishSession = true;
69-
}
62+
try {
63+
if (this._protocol.txnInProgress) {
64+
await this.rollback();
65+
}
66+
this._protocol.callTimeout = 0; // not applicable for close
67+
if (this._drcpEnabled) {
68+
await this._sessRelease();
69+
this._drcpEstablishSession = true;
70+
}
7071

71-
if (this._pool && !this._dropSess) {
72-
await this._pool.release(this);
73-
} else {
74-
if (!this._drcpEnabled) {
75-
const message = new messages.LogOffMessage(this);
76-
await this._protocol._processMessage(message);
72+
if (this._pool && !this._dropSess) {
73+
await this._pool.release(this);
74+
} else {
75+
if (!this._drcpEnabled) {
76+
const message = new messages.LogOffMessage(this);
77+
await this._protocol._processMessage(message);
78+
}
79+
this.nscon.disconnect();
7780
}
78-
this.nscon.disconnect();
81+
} catch (err) {
82+
// immediate close of open socket on failure
83+
// exception won't be thrown to user
84+
this.nscon.disconnect(sqlNetConstants.NSFIMM);
7985
}
8086
}
8187

0 commit comments

Comments
 (0)