libra-core
libra-core copied to clipboard
[BUG]Error when importing
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.
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.
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.