vacuumlabs / adalite-backend-service

Icarus, a reference implementation for a lightweight wallet developed by the IOHK Engineering Team.
Apache License 2.0
2 stars 7 forks source link

Instance failing with cardano-crypto unhandled exception #87

Open refi93 opened 4 years ago

refi93 commented 4 years ago

When fetching info about address (cardano-rest-integration branch), it sometimes fails with

/usr/app/node_modules/cardano-crypto.js/lib.js:1
var Module=typeof Module!=="undefined"?Module:{};var moduleOverrides={};var key;for(key in Module){if(Module.hasOwnProperty(key)){moduleOverrides[key]=Module[key]}}Module["arguments"]=[];Module["thisProgram"]="./this.program";Module["quit"]=(function(status,toThrow){throw toThrow});Module["preRun"]=[];Module["postRun"]=[];var ENVIRONMENT_IS_WEB=false;var ENVIRONMENT_IS_WORKER=false;var ENVIRONMENT_IS_NODE=false;var ENVIRONMENT_IS_SHELL=false;ENVIRONMENT_IS_WEB=typeof window==="object";ENVIRONMENT_IS_WORKER=typeof importScripts==="function";ENVIRONMENT_IS_NODE=typeof process==="object"&&typeof require==="function"&&!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_WORKER;ENVIRONMENT_IS_SHELL=!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_NODE&&!ENVIRONMENT_IS_WORKER;if(ENVIRONMENT_IS_NODE){var nodeFS;var nodePath;Module["read"]=function shell_read(filename,binary){var ret;ret=tryParseAsDataURI(filename);if(!ret){if(!nodeFS)nodeFS=require("fs");if(!nodePath)nodePath=require("path");f
Error [ERR_UNHANDLED_ERROR]: Unhandled error. (IncomingMessage {
  _readableState:
   ReadableState {
     objectMode: false,
     highWaterMark: 16384,
     buffer: BufferList { head: null, tail: null, length: 0 },
     length: 0,
     pipes: null,
     pipesCount: 0,
     flowing: true,
     ended: true,
     endEmitted: true,
     reading: false,
     sync: true,
     needReadable: false,
     emittedReadable: false,
     readableListening: false,
     resumeScheduled: false,
     paused: false,
     emitClose: true,
     autoDestroy: false,
     destroyed: false,
     defaultEncoding: 'utf8',
     awaitDrain: 0,
     readingMore: true,
     decoder: null,
     encoding: null },
  readable: false,

We were unable to reproduce it locally as of now, it will likely need debugging in prod

PeterBenc commented 4 years ago

I've encountered this issue while developing the tests for the new infrastructure. The error wasn't cause by cardano-crypto.js in any sense. It was caused by passing invalid argument( or incorrect number of arguments ) to dbApi call. This stackoverflow issue helped me solved the problem. It might or might not be the case but based on my experience, awaiting the promise from the db throws the error.

One suggestion would be to look into this function weather we don't pass to some of the dbAbi calls some undefined values or anything. https://github.com/vacuumlabs/adalite-backend-service/blob/3f706970b61965f030e9823ea2293801d6c3dcbb/src/legacy-routes.js#L79

I resolved my issue by altering the function in dbApi.js so it doesn't return the promise right away, but I assigned it to a variable and used .then().catch(). Logging the caught error should give us the answer imho.