SAP / node-rfc

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

TypeError: Client constructor requires an argument #185

Closed wush2000 closed 4 years ago

wush2000 commented 4 years ago

Hello, according to your documentation try catch is working but at least in case of wrong ip or wrong username/password it doesnt work for me. While the trace log is showing hostname 'asdf' unknown the app just crash with this: throw new TypeError(Client constructor requires an argument);

Can you confirm please ?

Example Code:

   try { 
   var rfcClient = await rfcPool.acquire();
       } catch (e) {
    console.log(e);
}

thank you

bsrdjan commented 4 years ago

The TypeError: Client constructor requires an argument is raised only when the Client constructor is called without any backend connection parameter (no user, passwd, ashost etc.). If credentials or connection parameters are wrong, different error is raised.

The TypeError: Client constructor requires an argument is raised:

const client = new require('node-rfc').Client();
const client = new require('node-rfc').Client({ dest: "ZZZ" });
// or
const pool = new require('node-rfc').Pool({ connectionParameters: { dest: "ZZZ" } });

Hope this helps.

wush2000 commented 4 years ago

Following code is working and as soon as I change any connection parameter (abapSystem) to something wrong the app still just crash. I would like to have a proper error message in case of wrong username/password. I wonder if that is possible.

Complete Code:

const abapSystem =   {
    SYSNR:'00',
    ASHOST:'v75',
    CLIENT:'800',
    USER:'ddic',
    PASSWD:'password',
    LANG:'en',
    CODEPAGE:'8400',
    TRACE:'2'
};

const noderfc  =  require ('node-rfc');
const pool =  new noderfc.Pool({ connectionParameters: abapSystem, poolOptions: { low: 2, high: 10 }} );

  module.exports =  (async () =>  {
       try { 
       var rfcClient = await pool.acquire();
       var download = await rfcClient.call("BAPI_USER_GETLIST", {MAX_ROWS: 10});  
            } catch (err) {
        console.log(err);
            }
            finally {
        rfcClient.release();
        console.log("entering and leaving the finally block");
    return download;             
}

})();
bsrdjan commented 4 years ago

Thank you for the example. Yes, it is bug, now fixed and shipped in 2.3.1 release.

Errors are raised like in pool/errors.spec.js unit tests.

wush2000 commented 4 years ago

Hello ! you are amazing! Thank you so much. Cannot wait to test it. but, I am afraid, currently im having problems to update node-rfc. Im pretty surprised and lost for now.

Even a fresh installation goes wrong: Command-Line: https://pastebin.com/GaTxuwMr Log: https://pastebin.com/EEcE2Y66

Is it a personal problem or could it maybe a problem in general ? Any hint would be highly appreciated .

bsrdjan commented 4 years ago

Yes, the general problem, will be fixed in next release.

The installation and build from source work for N-API 7 node versions only: >= 12.19.0, >= 14.12.0.

For now, you can install with these N-API 7 node versions and use from any node-version.

wush2000 commented 4 years ago

Thank you for the instruction.

I have tested all scenarios I could think of and its just working perfect. Thank you. Ticket can be closed.

bsrdjan commented 4 years ago

Glad to hear. I will open another ticket for the installation issue.