libra-core icon indicating copy to clipboard operation
libra-core copied to clipboard

[BUG]Error when importing

Open Steve-Mc opened this issue 5 years ago • 2 comments

The following line

import { LibraClient, LibraNetwork } from 'libra-core'

causes an error for me when used i angular. The error is:

index.js:3 Uncaught TypeError: Cannot read property '_handle' of undefined at index.js:3 at Array.forEach (<anonymous>) at module.exports (index.js:2) at Object.<anonymous> (log.js:11) at Object.213._process (log.js:310) at o (_prelude.js:1) at _prelude.js:1 at Object.<anonymous> (napi.js:5) at Object.211._process (napi.js:204) at o (_prelude.js:1)

Seems to be: if (stream._handle && stream.isTTY && typeof stream._handle.setBlocking === 'function')

causing the issue.

When using require with node I receive an Unexpected Identifier error when trying to require the package.

Steve-Mc avatar Jun 28 '19 16:06 Steve-Mc

I get the same error when trying to run in react:

TypeError: Cannot read property '_handle' of undefined
(anonymous function)
node_modules/libra-core/node_modules/grpc/node_modules/set-blocking/index.js:3
  1 | module.exports = function (blocking) {
  2 |   [process.stdout, process.stderr].forEach(function (stream) {
> 3 |     if (stream._handle && stream.isTTY && typeof stream._handle.setBlocking === 'function') {
  4 |       stream._handle.setBlocking(blocking);
  5 |     }
  6 |   });

I believe the problem is that to use grpc for the web you need to use the grpc-web package instead of grpc, which appears to be a somewhat different interface.

jeffslofish avatar Jun 28 '19 20:06 jeffslofish

Yes, I recently realized this grpc not working in the web. I plan to look into this as soon as I finish with other features currently in the pipeline.

perfectmak avatar Jun 29 '19 10:06 perfectmak