mirror of
https://github.com/zedeus/nitter
synced 2026-09-05 14:49:32 +00:00
Fix crash when TID pair fetch fails
This commit is contained in:
parent
6b86aaa27f
commit
0375145ea2
1 changed files with 4 additions and 2 deletions
|
|
@ -16,14 +16,16 @@ var
|
||||||
|
|
||||||
proc getPair(): Future[TidPair] {.async.} =
|
proc getPair(): Future[TidPair] {.async.} =
|
||||||
if cachedPairs.len == 0 or int(epochTime()) - lastCached > ttlSec:
|
if cachedPairs.len == 0 or int(epochTime()) - lastCached > ttlSec:
|
||||||
lastCached = int(epochTime())
|
|
||||||
|
|
||||||
let client = newAsyncHttpClient()
|
let client = newAsyncHttpClient()
|
||||||
defer: client.close()
|
defer: client.close()
|
||||||
|
|
||||||
let resp = await client.get(pairsUrl)
|
let resp = await client.get(pairsUrl)
|
||||||
if resp.status == $Http200:
|
if resp.status == $Http200:
|
||||||
cachedPairs = parseTidPairs(await resp.body)
|
cachedPairs = parseTidPairs(await resp.body)
|
||||||
|
lastCached = int(epochTime())
|
||||||
|
|
||||||
|
if cachedPairs.len == 0:
|
||||||
|
raise newException(ValueError, "Failed to fetch x-client-transaction-id pairs")
|
||||||
|
|
||||||
return sample(cachedPairs)
|
return sample(cachedPairs)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue