Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: Client constructor requires an argument #185

Closed
wush2000 opened this issue Nov 17, 2020 · 7 comments
Closed

TypeError: Client constructor requires an argument #185

wush2000 opened this issue Nov 17, 2020 · 7 comments
Labels

Comments

@wush2000
Copy link

wush2000 commented Nov 17, 2020

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
Copy link
Contributor

bsrdjan commented Nov 17, 2020

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:

  • with the direct client, when no connection parameters are given:
const client = new require('node-rfc').Client();
  • with the direct or managed client, when the given destination does not exist in sapnwrfc.ini:
const client = new require('node-rfc').Client({ dest: "ZZZ" });
// or
const pool = new require('node-rfc').Pool({ connectionParameters: { dest: "ZZZ" } });

Hope this helps.

@bsrdjan bsrdjan changed the title Try Catch TypeError: Client constructor requires an argument Nov 17, 2020
@wush2000
Copy link
Author

wush2000 commented Nov 17, 2020

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 bsrdjan added the bug label Nov 18, 2020
@bsrdjan bsrdjan reopened this Nov 18, 2020
@bsrdjan
Copy link
Contributor

bsrdjan commented Nov 18, 2020

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
Copy link
Author

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
Copy link
Contributor

bsrdjan commented Nov 20, 2020

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
Copy link
Author

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
Copy link
Contributor

bsrdjan commented Nov 20, 2020

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

@bsrdjan bsrdjan closed this as completed Nov 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants