ProjectLibertyLabs / gateway

Gateway microservices for DSNP/Frequency
https://projectlibertylabs.github.io/gateway/
Apache License 2.0
4 stars 1 forks source link

fix: make account service scanner the same as graph #661

Closed mattheworris closed 2 weeks ago

mattheworris commented 2 weeks ago

Problem

account-service can crash if it loses connection to the blockchain

2024-10-24 16:16:50          API-WS: disconnected from wss://0.rpc.testnet.amplica.io/: 1006:: Abnormal Closure
[Nest] 76924  - 10/24/2024, 4:16:50 PM   ERROR [BlockchainService] Communications error with Frequency node; starting 60-second shutdown timer
2024-10-24 16:16:50        RPC-CORE: getBlockHash(blockNumber?: BlockNumber): BlockHash:: disconnected from wss://0.rpc.testnet.amplica.io/: 1006:: Abnormal Closure
[Nest] 76924  - 10/24/2024, 4:16:50 PM   ERROR [TxnNotifierService] Unexpected error scanning chain
[Nest] 76924  - 10/24/2024, 4:16:50 PM   ERROR [TxnNotifierService] {}
Error: disconnected from wss://0.rpc.testnet.amplica.io/: 1006:: Abnormal Closure
    at WebSocket.__internal__onSocketClose (/Users/mattheworris/projects/fresh-gateway/node_modules/@polkadot/api/node_modules/@polkadot/rpc-provider/cjs/ws/index.js:355:23)
    at callListener (/Users/mattheworris/projects/fresh-gateway/node_modules/ws/lib/event-target.js:290:14)
    at WebSocket.onClose (/Users/mattheworris/projects/fresh-gateway/node_modules/ws/lib/event-target.js:220:9)
    at WebSocket.emit (node:events:518:28)
    at WebSocket.emitClose (/Users/mattheworris/projects/fresh-gateway/node_modules/ws/lib/websocket.js:272:10)
    at Receiver.receiverOnFinish (/Users/mattheworris/projects/fresh-gateway/node_modules/ws/lib/websocket.js:1209:20)
    at Receiver.emit (node:events:518:28)
    at finish (node:internal/streams/writable:946:10)
    at node:internal/streams/writable:927:13
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
****** UNCAUGHT EXCEPTION ****** Error: disconnected from wss://0.rpc.testnet.amplica.io/: 1006:: Abnormal Closure
    at WebSocket.__internal__onSocketClose (/Users/mattheworris/projects/fresh-gateway/node_modules/@polkadot/api/node_modules/@polkadot/rpc-provider/cjs/ws/index.js:355:23)
    at callListener (/Users/mattheworris/projects/fresh-gateway/node_modules/ws/lib/event-target.js:290:14)
    at WebSocket.onClose (/Users/mattheworris/projects/fresh-gateway/node_modules/ws/lib/event-target.js:220:9)
    at WebSocket.emit (node:events:518:28)
    at WebSocket.emitClose (/Users/mattheworris/projects/fresh-gateway/node_modules/ws/lib/websocket.js:272:10)
    at Receiver.receiverOnFinish (/Users/mattheworris/projects/fresh-gateway/node_modules/ws/lib/websocket.js:1209:20)
    at Receiver.emit (node:events:518:28)
    at finish (node:internal/streams/writable:946:10)
    at node:internal/streams/writable:927:13
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)

Solution

Implement the same updates as graph service, which does not exhibit the problem.

Steps to Verify:

  1. Run account service connected to a local node.
  2. Stop the local frequency node.
  3. Verify that account-service does not crash due to the unhandled exception above.