blockcollider / bcnode

Mining node and rovers for the five genesis chains of Block Collider.
https://www.blockcollider.org
MIT License
45 stars 23 forks source link

Serialize exception correctly even if stack contains circular reference #212

Closed akloboucnik closed 6 years ago

akloboucnik commented 6 years ago

reported by @equilibriumzen in Advanced telegram channel.

...
2018-05-03T08:20:31.786Z ERROR  p2p.node Error: websocket error
/src/lib/cli/main.js:108
    fs.writeFile(EXCEPTION_PATH, JSON.stringify(errToObj(err), null, 2), err => {
                                      ^
2018-05-03T08:20:31.852593309Z
TypeError: Converting circular structure to JSON
    at JSON.stringify (<anonymous>)
    at process.on.err (/src/lib/cli/main.js:108:39)
    at emitOne (events.js:121:20)
    at process.emit (events.js:211:7)
    at process._fatalException (bootstrap_node.js:375:26)
UNCAUGHT EXCEPTION, saving in exception.log { Error: websocket error
    at WS.Transport.onError (/src/node_modules/socket.io-client/node_modules/engine.io-client/lib/transport.js:64:13)
    at WebSocket.ws.onerror (/src/node_modules/socket.io-client/node_modules/engine.io-client/lib/transports/websocket.js:150:10)
    at WebSocket.onError (/src/node_modules/ws/lib/EventTarget.js:109:16)
    at emitOne (events.js:116:13)
...

see https://pastebin.com/y6EG9EXX