`zola serve --open` stuck loading the page

Hi hi, my first post here :slight_smile:

Anyone knows why running zola serve --open launches the browser, but the page never loads? The page stays blank, and the browser keeps spinning as if the web page was hosted very very far away.

The odd thing is, the same files, on a different computer, instantly open the page as expected.

So this happens in one computer, but not in another. Both are up-to-date Manjaro Linux. The zola project is located in an external SSD disk, which I mount on both computers.

The computers run fine with all kinds of daily multimedia and dev tasks I perform on both.

Any tips? Thanks!

ps. v0.23.6

Does the non-working system show any errors or access attempts in the console? Anything in the browser console? A number of things could be blocking it, and knowing if it’s reaching zola or not would be helpful.

The terminal shows

$ zola serve --open
Building site...
-> Creating 68 pages (0 orphan) and 12 sections
Done in 409ms.

Listening for changes in /home/funpro/datasea/OR/openrndr.org/guide/build/dokgen/zola/{config.toml,content,static,templates}
Press Ctrl+C to stop

Web server is available at http://127.0.0.1:1111 (bound to 127.0.0.1:1111)

The web page is completely blank, including its console. The name of the tab is 127.0.0.1:1111/ and has a dot moving left and right, as “waiting for the request to return something”. I tried with three different web browsers simultaneously and all do the same, as if something is blocking the request.

I figured out that this makes it work: XDG_CURRENT_DESKTOP=GNOME zola serve --open

I’m on i3wm, and the default browser is librewolf. Based on what I read, xdg-open might not be exiting and running the browser in the foreground instead. If I close the browser and open it again, I can load the page. I’m OK with the current workaround, but sharing this in case it can be fixed in zola… Thanks!

Did you try an AI?
For instance, here is what Hy4 Flash (free version) suggested by reading your messages:

Short answer

It’s not the network, the browsers, or the external SSD. On that machine xdg-open never returns, and Zola calls it synchronously on the server’s single-threaded async runtime, before axum::serve() starts accepting connections. The TCP listener is already bound, so browsers connect fine — but nothing ever reads their requests. Hence a blank tab that spins forever in every browser.

Closing the browser is what unblocks xdg-open, which lets Zola finally reach axum::serve(); that’s why opening the URL again then works. XDG_CURRENT_DESKTOP=GNOME works because it switches xdg-open to the gio open path, which hands the URL off over D-Bus and returns immediately.

The exact code path (Zola v0.23.6, src/cmd/serve.rs)

thread::spawn(move || {
    let rt = tokio::runtime::Builder::new_current_thread()   // line 634: ONE thread
        ...
    rt.block_on(async {
        let listener = tokio::net::TcpListener::bind(&bind_address).await   // 649: socket now LISTENing
            .expect("Could not bind to address");
        ...
        if open && let Err(err) = open::that(&constructed_base_url) {        // 660: blocking call
            log::error!("Failed to open URL in your browser: {err}");
        }
        axum::serve(listener, app).await                                     // 664: only now do we accept
    });
});

And open (0.23.6 locks open 5.4.4) does wait for the launcher:

pub fn that(path: impl AsRef<OsStr>) -> io::Result<()> {
    ...
    match cmd.status_without_output() { ... }   // = Command::status() → waits for xdg-open to exit
}

The crate’s own docs warn about exactly this: “Sometimes, depending on the platform and system configuration, launchers can block. If you want to be sure they don’t, use that_in_background() or that_detached.”

Why it happens on i3 + LibreWolf

xdg-open 1.2.1 (Manjaro) dispatches on XDG_CURRENT_DESKTOP. With i3 it lands in DE=generic, and the generic URL path ends in either:

  • open_generic_xdg_x_scheme_handler → env "$command" "$@" (waits for the desktop-file Exec), or
  • open_envvar → $browser "$url" with no & — it waits for the browser to exit before exit_success.

LibreWolf launched fresh (no already-running instance) stays in the foreground, so xdg-open waits for the whole browsing session. With XDG_CURRENT_DESKTOP=GNOME, xdg-open takes open_gnome → gio open, which uses GIO/D-Bus activation and returns straight away. That is exactly the workaround they found.

Why every symptom fits

Observation Explanation
Spinner, blank page, empty browser console The request was never read; no response headers ever come back
No “connection refused” TcpListener::bind already did listen(); the kernel completes the handshake and queues the connection
Three different browsers all hang The accept loop hasn’t started at all — it’s not browser-specific
Closing the browser fixes it xdg-open exits → open::that returns → axum::serve starts → the next tab load works
Other computer is fine Its xdg-open takes a non-blocking path (GNOME/KDE/gio open, or the browser was already running)
Same external SSD, same files Irrelevant — the difference is the launcher configuration

2-minute confirmation

zola serve                 # no --open; open http://127.0.0.1:1111 manually → should load instantly
pgrep -a xdg-open          # while the tab spins: xdg-open is alive as a child of zola
pstree -p "$(pgrep -f 'zola serve')"   # or: ps -o pid,ppid,stat,cmd --forest
time xdg-open http://127.0.0.1:1111    # prompt returns only when the browser is closed

Also: start LibreWolf first, then zola serve --open — it should work, because librewolf URL hands off to the existing instance and exits immediately.

Fix for the user / upstream

Workarounds: zola serve without --open (cleanest), their XDG_CURRENT_DESKTOP=GNOME trick, or pre-starting the browser.

The real fix is a 3-line Zola patch — never call the opener on the runtime thread:

if open {
    // open::that() waits for xdg-open, which can run the browser in the foreground.
    let _ = open::that_in_background(constructed_base_url.clone());
}
axum::serve(listener, app).await.expect("Could not start web server");

(that_in_background exists in open 5.4.4; that_detached would also work.) Since the listener is already bound, opening the browser before axum::serve is polled is safe — connections just queue.

I can’t verify which xdg-open branch fires on their box (BROWSER vs. xdg-mime default), but both wait for the browser, so the conclusion is the same.