AmbireTech / adex-market

AdEx Market: a scraper that aggregates ad campaign information from the validator network
7 stars 6 forks source link

Handle 404 when updating status #148

Open Ivshti opened 4 years ago

Ivshti commented 4 years ago

Behavior

When the channel is not submitted to one of the validators, an exception occurs:

=== ERROR IN GET REQUEST ===
Error: Fetch error at "https://jerry.moonicorn.network/channel/0x185ae00b64202387ce62468a0689e5bc31ba4dca8eace0bdd6d28e5cd3b5ff8c/last-approved?withHeartbeat=true", status: [404] Not Found, err: null 
    at /home/ivo/repos/adex-market/helpers/getRequest.js:11:11
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async Promise.all (index 0)
    at async getStatusOfCampaign (/home/ivo/repos/adex-market/status-loop/queryValidators.js:100:57)
    at async Promise.all (index 0)
    at async queryValidators (/home/ivo/repos/adex-market/status-loop/queryValidators.js:214:2)
(node:3794577) UnhandledPromiseRejectionWarning: Error: Error: Fetch error at "https://jerry.moonicorn.network/channel/0x185ae00b64202387ce62468a0689e5bc31ba4dca8eace0bdd6d28e5cd3b5ff8c/last-approved?withHeartbeat=true", status: [404] Not Found, err: null 
    at /home/ivo/repos/adex-market/helpers/getRequest.js:19:10
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async Promise.all (index 0)
    at async getStatusOfCampaign (/home/ivo/repos/adex-market/status-loop/queryValidators.js:100:57)
    at async Promise.all (index 0)
    at async queryValidators (/home/ivo/repos/adex-market/status-loop/queryValidators.js:214:2)
(node:3794577) 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(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:3794577) [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.

Expected behavior

Either catch the 404 and don't set a status (skip it) or set a status that's appropriate, e.g Initializing - the problem with this is that the other properties will be missing.

To be discussed.

elpiel commented 4 years ago

Good catch! I think even in the Rust impl it will cause similar issue.

  1. First the issue will come from is_finalized(), since we call the Leader
  2. The second time is before calling is_initializing() for the Follower.

These are the 2 places we need to fix.

I propose the following:

TODOs in Rust get_status()

Regarding the status @Ivshti , there shouldn't be a problem. We return the Leader BalancesMap with the Status::Initializing and we can just return an empty one.