Skip to content

Commit 97750e0

Browse files
committed
Error recovery message improvements
1 parent 04319fb commit 97750e0

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

doc/src/release_notes.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ Thin Mode Changes
1717
response that spans multiple packets. This break could occur due to a
1818
server error, the session being killed or a call to `breakExecution()`.
1919

20+
#) Improve error message when an internal error handler fails and a connection
21+
is no longer usable.
22+
2023
node-oracledb `v6.0.2 <https://github.com/oracle/node-oracledb/compare/v6.0.1...v6.0.2>`__ (27 Jun 2023)
2124
--------------------------------------------------------------------------------------------------------
2225

lib/thin/protocol/protocol.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ class Protocol {
111111
this.writeBuf.endRequest();
112112
}
113113

114-
async _recoverFromError(message) {
114+
async _recoverFromError(caughtErr, message) {
115115
/*
116116
* We have NJS error(protocol related) detected during packet write/read
117117
* operation. Issue a break and reset to clear channel . We receive the
@@ -124,10 +124,12 @@ class Protocol {
124124
await this.readBuf.waitForPackets();
125125
message.decode(this.readBuf);
126126
} catch (err) { // Recovery failed
127-
// TODO: throw different error indicating that reset failed, probably
128-
// put inside resetMessage()
129127
this.nsi.disconnect();
130-
errors.throwErr(errors.ERR_CONNECTION_CLOSED);
128+
const newErr = errors.getErr(errors.ERR_CONNECTION_CLOSED);
129+
caughtErr.message = newErr.message +
130+
"\nError recovery failed: " + err.message +
131+
"\nOriginal error: " + caughtErr.message;
132+
throw caughtErr;
131133
}
132134
}
133135

@@ -153,7 +155,7 @@ class Protocol {
153155
} catch (err) {
154156
if (!this.connInProgress &&
155157
err.code !== errors.ERR_CONNECTION_CLOSED_CODE) {
156-
await this._recoverFromError(message);
158+
await this._recoverFromError(err, message);
157159
}
158160
throw err;
159161
} finally {

0 commit comments

Comments
 (0)