(node:6820) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'message' of undefined
at new ApiError (...\js\dblock-timestamp\node_modules\factom\src\apis-cli.js:37:45)
at ...\js\dblock-timestamp\node_modules\factom\src\apis-cli.js:162:41
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
Trying to connect to the open node with:
const cli = new FactomCli({
factomd: {
host: 'api.factomd.net',
port: 443,
// protocol: 'https' intentionally commented out to trigger the error
}
});
cli.getDirectoryBlockHead()
Seems like the API expects the server to return a json-rpc formatted error message with a code 400 but the open node sends back a regular server error:
<html>
<head><title>400 The plain HTTP request was sent to HTTPS port</title></head>
<body bgcolor="white">
<center><h1>400 Bad Request</h1></center>
<center>The plain HTTP request was sent to HTTPS port</center>
<hr><center>cloudflare</center>
</body>
</html>
which then causes a null pointer in the ApiError constructor!
Wow this automated closure is a bit brutal hehe
Thank you for reporting this, I am now properly distinguishing RPC errors (which are objects with a message field) from others. It has been published in v1.2.5.
Just encountered the following error:
Trying to connect to the open node with:
Seems like the API expects the server to return a json-rpc formatted error message with a code 400 but the open node sends back a regular server error:
which then causes a null pointer in the ApiError constructor!