vocdoni/bridge-ui

Promise.all fails early with potentially non existing process ID's

Closed this issue · 1 comments

Displaying process entries may fail on the UI due to a (still) unresolved ID duplication issue. Until an update is available, the global process refreshing routine needs to be resilient to this.

The root cause is a Promise.all() where N process ID's are resolved to the actual data+parameters. Some of these process ID's will fail to resolve immediately, while the valid ones will take longer.

Since Promise.all() will reject on the first failure, the rest of (legitimate) data fetches are ignored right away. This causes the UI to not have any process to display.

The root of the issue may be here:

bridge-ui/lib/api.ts

Lines 17 to 26 in a0005d9

export async function getTokenProcesses(tokenAddr: string, pool: GatewayPool): Promise<ProcessInfo[]> {
return getProcessList(tokenAddr, pool)
.catch(err => {
if (err?.message?.includes("Key not found")) { return [] as string[] }
throw err
})
.then(tokenProcessIds => Promise.all(tokenProcessIds.map(
processId => getProcessInfo(processId, pool))
))
}

So, in order to avoid a problem, we may want to return a null value in case of error and ignore the null entry afterwards.