spacedriveapp/spacedrive · error
Failed to create HTTP client
Error message
Failed to create HTTP client
What it means
main builds a reqwest-backed HTTP client (gpui ReqwestClient::user_agent) for image loading and expects construction to succeed. user_agent returns Err only when the underlying reqwest Client cannot be built, essentially always a TLS backend initialization failure or process resource exhaustion at startup. The expect converts that rare condition into an immediate panic.
Source
Thrown at apps/gpui-photo-grid/src/main.rs:29
// Get configuration from environment
let socket_addr = env::var("SD_SOCKET_ADDR").unwrap_or_else(|_| "127.0.0.1:6969".to_string());
let http_url = env::var("SD_HTTP_URL").unwrap_or_else(|_e| "http://127.0.0.1:56851".to_string());
let library_id = env::var("SD_LIBRARY_ID").expect("SD_LIBRARY_ID environment variable must be set");
let initial_path = env::var("SD_INITIAL_PATH").unwrap_or_else(|_e| "/Users/jamespine/Desktop".to_string());
println!("Starting GPUI Photo Grid");
println!(" Socket: {}", socket_addr);
println!(" HTTP: {}", http_url);
println!(" Library: {}", library_id);
println!(" Path: {}", initial_path);
// Create HTTP client for image loading
let http_client = Arc::new(
reqwest_client::ReqwestClient::user_agent("spacedrive-gpui")
.expect("Failed to create HTTP client"),
);
Application::new()
.with_http_client(http_client)
.run(move |cx: &mut App| {
cx.activate(true);
cx.open_window(
WindowOptions {
window_bounds: Some(WindowBounds::Windowed(Bounds::centered(
None,
size(px(1200.0), px(800.0)),
cx,
))),
titlebar: Some(TitlebarOptions {
title: Some("Spacedrive Media Grid".into()),
appears_transparent: false,
..Default::default()View on GitHub (pinned to 6dfeccf211)
Solutions
- Rebuild with the crate's default feature set (rustls) and unchanged dependencies
- Check process limits (ulimit -n) and memory if construction fails at startup
- If reproducible with default features, capture the inner error before the expect and report it as a build/toolchain issue
Example fix
// before: expect hides the underlying cause
ReqwestClient::user_agent("spacedrive-gpui").expect("Failed to create HTTP client");
// after: surface the inner error on failure
let http_client = ReqwestClient::user_agent("spacedrive-gpui")
.unwrap_or_else(|e| panic!("Failed to create HTTP client: {e}")); Defensive patterns
Strategy: fallback
Try / catch
// Construction happens once at startup; on failure print the inner error and exit non-zero
let client = match ReqwestClient::user_agent("spacedrive-gpui") {
Ok(c) => Arc::new(c),
Err(e) => {
eprintln!("HTTP client construction failed: {e}");
std::process::exit(1);
}
}; Prevention
- Build the client once and reuse it; do not construct clients per request
- Keep default TLS features intact in builds that ship
- Treat construction failure as an environment/build defect, not a runtime condition
When it happens
Trigger: TLS backend init failure (broken rustls/native-tls feature mix in the build); fd/memory exhaustion at process start; exotic sandboxed environments blocking client construction.
Common situations: Custom build with TLS features stripped or conflicting; almost never seen in stock builds.
Related errors
- failed to register Alt+Space global shortcut
- Cannot set key: {}
- Failed to start systemd service: {}
- Daemon exited with error: {}
- Could not determine home directory
AI-assisted analysis of spacedriveapp/spacedrive@6dfeccf211 (2026-08-16).
Data as JSON: /api/errors/51d42c9a7fab9b59.
Report an issue: GitHub.