The connection (result from oracle.connect) does not retain the oracle client so if the garbage collector (Mark-sweep) is run it will collect the client even if a connection is still open (OracleClient destructor is called) and the next call to a client function that depends on m_environment will crash.
I added a simple example for reproduction. you have to run it with node --expose-gc crash.js.
crash.js content:
var connectData = {
host: '127.0.0.1',
database: 'XE',
user: 'user',
password: 'password'
};
oracle.connect(connectData, function (err, connection) {
// var oracle2 = oracle; // will work if comment is removed
if (err) {
throw new Error(err);
}
global.gc();
var execResult = connection.executeSync(
'SELECT 1 from DUAL',
[]
);
console.log("RESULT", execResult);
connection.close();
});
If the comment-out code is reinserted oracle (OracleClient) will not be garbage collected because it's used inside the function.
FWIW: This was tested with occi 12.1.0.1.0 and 12.1.0.2.0 with Linux and node 4 and 6.
The connection (result from
oracle.connect
) does not retain the oracle client so if the garbage collector (Mark-sweep) is run it will collect the client even if a connection is still open (OracleClient destructor is called) and the next call to a client function that depends onm_environment
will crash.I added a simple example for reproduction. you have to run it with
node --expose-gc crash.js
.crash.js content:
If the comment-out code is reinserted
oracle
(OracleClient) will not be garbage collected because it's used inside the function.FWIW: This was tested with occi 12.1.0.1.0 and 12.1.0.2.0 with Linux and node 4 and 6.