Hi all,
I just started following the basic course and I was blocked for a while on the Pocket-IC startup executing dfx start --clean
.
The command was throwing 502 Bad Gateway with no more logs, even by running the command with RUST_LOG="trace"
.
ERROR: Failed to initialize HTTP gateway: HTTP status server error (502 Bad Gateway) for url (http://localhost:65420/http_gateway)
⠖ Starting local network...
I decided to debug it and after building the pocket-ic-server
and adding some additional logs to it to find out the error I’ve obtained Error parsing resolv.conf: Malformed label:
.
I’ve figured out this way that my resolv.conf
was in a wrong format (this was not causing any issue in any other program since years).
The main point here is that the actual logging does not allow to see this and to figure it out it’s time consuming.
So I hope to help anyone facing the same issue and maybe add a tip on how to improve the debug logging.
OS: MacOs
Dfx version: 0.27.0 and 0.28.0-beta.1
Thank you!
Could you please share more details what additional information you logged so that we can see if those extra logs could be useful in general?
Hi sure:
Inside the IC project under /rs/pocket_ic_server/src/state_api/state.rs
.
I replaced:
time::timeout(DEFAULT_SYNC_WAIT_DURATION, agent.fetch_root_key())
.await
.map_err(|_| format!("{} (timeout)", UPSTREAM_ERROR))?
.map_err(|e| format!("{} ({})", UPSTREAM_ERROR, e))?;
With something like:
let result = time::timeout(DEFAULT_SYNC_WAIT_DURATION, agent.fetch_root_key())
.await;
debug!("Timeout result: {:?}", result);
result
.map_err(|_| {
error!("fetch_root_key timed out");
format!("{} (timeout)", UPSTREAM_ERROR)
})?
.map_err(|e| {
error!("fetch_root_key failed: {}", e);
format!("{} ({})", UPSTREAM_ERROR, e)
})?;
The failing call was agent.fetch_root_key()
If you have a Mac and want to test it just place some wrong text inside /etc/resolv.conf
and then run dfx start --clean
Let me know if I can provide further info, thank you!
If we want to have those errors output, we could output them in dfx instead of only keeping the status code here. CC @AdamS
1 Like