It seems some exceptions are being raised within an awaited async function, but the program stops without a raised error. It also might have to do with cligen dispatching an async proc, although I have no idea how I would efficiently change this.
Reproducible Example:
import std/[asyncdispatch, httpclient]
type Idk = ref object
client: AsyncHttpClient
proc getFile(client: AsyncHttpClient, url: string): Future[string] {.async.} =
echo "u 25"
let response = await client.get(url)
echo "u 27"
proc main {.async.} =
let idk = Idk(client: newAsyncHttpClient())
let client = idk.client
echo await client.getFile("https://example.com")
import cligen; dispatch main
Nim Version
Nim Compiler Version 2.0.0 [Linux: amd64]
Compiled at 2023-08-01
Copyright (c) 2006-2023 by Andreas Rumpf
git hash: a488067a4130f029000be4550a0fb1b39e0e9e7c
active boot switches: -d:release
The program quits after "u 25" because the code generated by cligen.dispatch discards the Future returned by main.
Try making main non-async by replacing await client.getFile with waitFor client.getFile and removing the async pragma, or making a new proc calls waitFor on main and dispatching that instead.