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

Error related to grpc package #6

Open
asghaier76 opened this issue Aug 6, 2019 · 10 comments
Open

Error related to grpc package #6

asghaier76 opened this issue Aug 6, 2019 · 10 comments

Comments

@asghaier76
Copy link

I am trying to use this library in an Angular project and I am getting this error

ERROR in ./node_modules/grpc/node_modules/detect-libc/lib/detect-libc.js
Module not found: Error: Can't resolve 'child_process' in '../node_modules/grpc/node_modules/detect-libc/lib'

I am using

Node: 12.4.0
OS: darwin x64
Angular: 8.1.3

Any help on this issue?

Ahmad

@asghaier76 asghaier76 changed the title Error Error related to grpc package Aug 6, 2019
@totiz
Copy link
Contributor

totiz commented Aug 7, 2019

Have you upgrade to [email protected]? prior to this version, there's an issue when run on browser.

@asghaier76
Copy link
Author

Yes I am using [email protected]. Not sure if the issue is related to grpc.

@totiz
Copy link
Contributor

totiz commented Aug 12, 2019

@asghaier76 I don't have a skill on angular, could you please share me your project that I can run and reproduce the error, or perhaps the steps on setting the project to reproduce this error, thanks.

@asghaier76
Copy link
Author

@totiz I have sent you an invite to the repo

@asghaier76
Copy link
Author

@totiz have you had the chance to clone the repo and test

@totiz
Copy link
Contributor

totiz commented Aug 18, 2019

Ok I got it, I'll let you know if I try and have any update, thanks.

@totiz
Copy link
Contributor

totiz commented Aug 19, 2019

@asghaier76 Ok I run your project and got the error, This's a known error that doesn't cause Vue project to crash but on Angular I've never try (and React as well).

The problem:

grpc can not be load on browser, so I try to separate the require('grpc') by checking that the project run with grpc-web or not, then load.

Workaround:

  • Go to node_modules/kulap-libra/build/client/index.js
    and comment this line like this
// Init Admission Controller Proxy
        if (this.config.dataProtocol === 'grpc') {
            // this.admissionControlProxy = require('./Node');
        }

PS: you should upgrade to [email protected] for new minting protocol https://github.com/kulapio/libra-core/releases/tag/v1.0.15

Please let me know if you're still have problems.

And just leave this issue open, because we still need a patch for completely fix.

@asghaier76
Copy link
Author

asghaier76 commented Aug 22, 2019

@totiz while this fixes the error at compilation time still it brings issues in in run time

so after using the workaround and comment only this line

// this.admissionControlProxy = require('./Node');

I can compile and generate wallets but once try to connect to the Blockchain for example to retrieve balance I get this error

ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'initAdmissionControlClient' of undefined TypeError: Cannot read property 'initAdmissionControlClient' of undefined

and it fails to create an instance of LibraClient which I am initiating and querying balance using these lines

const client = new LibraClient({ network: LibraNetwork.Testnet }) console.log(client); const accountState = await client.getAccountState(this.address); console.log(accountState); // log account balance this.balance = accountState.balance.toString(); console.log(accountState.balance.toString());

It seems by commenting that line the admissionControlProxy is not defined, so I went on and commented the this section

// Init Admission Controller Proxy //if (this.config.dataProtocol === 'grpc') { //this.admissionControlProxy = require('./Node'); //} //else { this.admissionControlProxy = require('./Browser'); //}

so that admissionControlProxy is defined but I got another type of error

POST ac.testnet.libra.org:80/admission_control.AdmissionControl/UpdateToLatestLedger net::ERR_UNKNOWN_URL_SCHEME

The LibraClient object instance looks like

LibraClient {config: {…}, admissionControlProxy: {…}, acClient: p…h../…b.js.p…o.admissio…, decoder: ClientDecoder, encoder: ClientEncoder} acClient: push../node_modules/kulap-libra/build/__generated__/admission_control_grpc_web_pb.js.proto.admission_control.AdmissionControlPromiseClient client_: Y {a: "text", c: false, b: false} credentials_: null hostname_: "ac.testnet.libra.org:80" options_: {format: "text"} __proto__: Object admissionControlProxy: initAdmissionControlClient: ƒ initAdmissionControlClient(connectionAddress) submitTransaction: async ƒ submitTransaction(acClient, request) updateToLatestLedger: async ƒ updateToLatestLedger(acClient, request) __esModule: true __proto__: Object config: {network: "testnet", host: "ac.testnet.libra.org", port: "80", transferProtocol: "http", dataProtocol: "grpc"} decoder: ClientDecoder {} encoder: ClientEncoder {client: LibraClient} __proto__: Object

I am not sure if the ServersHost config file need to be modified

@totiz
Copy link
Contributor

totiz commented Aug 23, 2019

On the browser you need to init client with this code.

// On Browser
const client = new LibraClient({
  transferProtocol: 'https',
  host: 'ac-libra-testnet.kulap.io',
  port: '443',
  dataProtocol: 'grpc-web-text'
})

Please let me know if still has any problems.

@asghaier76
Copy link
Author

Thanks @totiz It works with this endpoint.

Great work Kulap team.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants