SAP / node-rfc

Asynchronous, non-blocking SAP NW RFC SDK bindings for Node.js
Apache License 2.0
251 stars 73 forks source link

RFC_INVALID_HANDLE: An invalid handle 'RFC_CONNECTION_HANDLE' was passed to the API call #133

Closed bsrdjan closed 4 years ago

bsrdjan commented 4 years ago

During an ongoing RFC call, the client requests closing the connection, because an application error for example. In certain cases, the RFC call ends with RFC_INVALID_HANDLE error:

The correct behaviour would be scheduling the connection close request after the RFC call is completed, not triggering immediately, during an ongoing RFC call.

lock.js

WAIT_SECONDS = 5;

TICK = 0

INTERVAL = 7

const T = setInterval(() => {
    console.log(++TICK);
    if (TICK === INTERVAL) clearInterval(T)
}, 1000)

client.connect((err, res) => {
    if (err) return console.error(err);
    console.log('connected');

    client.invoke('/COE/RBP_FE_WAIT', {
            IV_SECONDS: WAIT_SECONDS
        },
        err => {
            if (err) return console.error(err);
            console.log('executed');
        });

    client.close(
        err => {
            if (err) return console.error(err);
            console.log('closed');
        });
})
$ node ci/test/lock.js
{
  name: 'RfcLibError',
  code: 13,
  key: 'RFC_INVALID_HANDLE',
  message: "An invalid handle 'RFC_CONNECTION_HANDLE' was passed to the API call"
}
bsrdjan commented 4 years ago

Solved by 1.0.7 by raising an error if close() requested during ongoing RFC call.