I believe my JS SDK transactions are failing due to MyHbarWallet's proxy being down? If this is the case, can we potentially provide a better error message?
Pablo from Hashing Systems filed a seemingly related issue within the MHW repo here (#280) which actually made me realize this was likely the issue I was encountering.
Additionally, could someone clarify which client proxy config is correct for this release? (discussed in the additional attempts to resolve section)
Details
Running the get-account-info.js example for release v.0.8.0-beta.0
returns the following errors
(node:4974) UnhandledPromiseRejectionWarning: Error: 14 UNAVAILABLE: DNS resolution failed
at Object.exports.createStatusError (/Users/cooperkunz/Desktop/hide/Hedera-JS-Examples/test1/node_modules/grpc/src/common.js:91:15)
at Object.onReceiveStatus (/Users/cooperkunz/Desktop/hide/Hedera-JS-Examples/test1/node_modules/grpc/src/client_interceptors.js:1209:28)
at InterceptingListener._callNext (/Users/cooperkunz/Desktop/hide/Hedera-JS-Examples/test1/node_modules/grpc/src/client_interceptors.js:568:42)
at InterceptingListener.onReceiveStatus (/Users/cooperkunz/Desktop/hide/Hedera-JS-Examples/test1/node_modules/grpc/src/client_interceptors.js:618:8)
at callback (/Users/cooperkunz/Desktop/hide/Hedera-JS-Examples/test1/node_modules/grpc/src/client_interceptors.js:847:24)
(node:4974) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:4974) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Code
require("dotenv").config();
const { Client, AccountBalanceQuery } = require("@hashgraph/sdk");
async function main() {
const operatorPrivateKey = process.env.OPERATOR_KEY;
const operatorAccount = process.env.OPERATOR_ID;
if (operatorPrivateKey == null || operatorAccount == null) {
throw new Error("environment variables OPERATOR_KEY and OPERATOR_ID must be present");
}
const client = new Client({
network: { "https://grpc-web.myhederawallet.com": "0.0.3" },
operator: {
account: operatorAccount,
privateKey: operatorPrivateKey
}
});
const balance = await new AccountBalanceQuery()
.setAccountId(operatorAccount)
.execute(client);
console.log(`${operatorAccount} balance = ${balance.value()}`);
}
main();
Attempt to fix
On the readme for release v.0.8.0-beta.0
it says to proxy to the grpc-web.myhederawallet.com
domain, rather than the actual Node IP address that is included in the /examples
so I attempted to run this as well...
Updated code
require("dotenv").config();
const { Client, AccountBalanceQuery } = require("@hashgraph/sdk");
async function main() {
const operatorPrivateKey = process.env.OPERATOR_KEY;
const operatorAccount = process.env.OPERATOR_ID;
if (operatorPrivateKey == null || operatorAccount == null) {
throw new Error("environment variables OPERATOR_KEY and OPERATOR_ID must be present");
}
const client = new Client({
network: { "0.testnet.hedera.com:50211": "0.0.3" },
operator: {
account: operatorAccount,
privateKey: operatorPrivateKey
}
});
const balance = await new AccountBalanceQuery()
.setAccountId(operatorAccount)
.execute(client);
console.log(`${operatorAccount} balance = ${balance.value()}`);
}
main();
Which delayed for quite some time before returning the following response.
Updated error
(node:5056) UnhandledPromiseRejectionWarning: Error: 14 UNAVAILABLE: failed to connect to all addresses
at Object.exports.createStatusError (/Users/cooperkunz/Desktop/hide/Hedera-JS-Examples/test1/node_modules/grpc/src/common.js:91:15)
at Object.onReceiveStatus (/Users/cooperkunz/Desktop/hide/Hedera-JS-Examples/test1/node_modules/grpc/src/client_interceptors.js:1209:28)
at InterceptingListener._callNext (/Users/cooperkunz/Desktop/hide/Hedera-JS-Examples/test1/node_modules/grpc/src/client_interceptors.js:568:42)
at InterceptingListener.onReceiveStatus (/Users/cooperkunz/Desktop/hide/Hedera-JS-Examples/test1/node_modules/grpc/src/client_interceptors.js:618:8)
at callback (/Users/cooperkunz/Desktop/hide/Hedera-JS-Examples/test1/node_modules/grpc/src/client_interceptors.js:847:24)
(node:5056) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:5056) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
package.json
below, if it's of help
{
"name": "test1",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"@hashgraph/sdk": "^0.8.0-beta.0",
"dotenv": "^8.2.0"
}
}
Overall the v.0.8.0-beta.0
functionality is looking nice though - excited to test it out 🎊