wezterm/wezterm · error

no such window {window_id}

Error message

no such window {window_id}

What it means

Thrown by the wezterm mux server when a WindowTitleChanged PDU names a window_id that is not present in the server's Mux state (get_window_mut returns None). The mux server tracks windows by monotonically allocated integer ids; the failed lookup is returned to the client as an ErrorResponse on the mux protocol connection. It almost always means the window was closed, or the server restarted and renumbered, between the client learning the id and using it.

Source

Thrown at wezterm-mux-server-impl/src/sessionhandler.rs:890

                    move || {
                        let client_cert_pem = PKI.generate_client_cert()?;
                        let ca_cert_pem = PKI.ca_pem_string()?;
                        Ok(Pdu::GetTlsCredsResponse(GetTlsCredsResponse {
                            client_cert_pem,
                            ca_cert_pem,
                        }))
                    },
                    send_response,
                );
            }
            Pdu::WindowTitleChanged(WindowTitleChanged { window_id, title }) => {
                spawn_into_main_thread(async move {
                    catch(
                        move || {
                            let mux = Mux::get();
                            let mut window = mux
                                .get_window_mut(window_id)
                                .ok_or_else(|| anyhow!("no such window {window_id}"))?;

                            window.set_title(&title);

                            Ok(Pdu::UnitResponse(UnitResponse {}))
                        },
                        send_response,
                    )
                })
                .detach();
            }
            Pdu::TabTitleChanged(TabTitleChanged { tab_id, title }) => {
                spawn_into_main_thread(async move {
                    catch(
                        move || {
                            let mux = Mux::get();
                            let tab = mux
                                .get_tab(tab_id)
                                .ok_or_else(|| anyhow!("no such tab {tab_id}"))?;

View on GitHub (pinned to 08e5e0afc6)

Solutions

  1. Re-run `wezterm cli list --format json` and use a currently valid window_id before setting the title
  2. Treat 'no such window' as a benign lost race in scripts: detect it and skip/ignore rather than abort
  3. Re-list windows (or subscribe to PaneRemoved/lifecycle events) right before acting on a cached id so cached ids stay fresh
  4. Verify WEZTERM_UNIX_SOCKET / --id-file point to the same mux server that owns the window

Example fix

# before
wezterm cli set-window-title --window-id $STALE_ID 'my title'  # -> no such window

# after: re-resolve a live window id first
wid=$(wezterm cli list --format json | jq -r '.[0].window_id')
wezterm cli set-window-title --window-id "$wid" 'my title'
Defensive patterns

Strategy: validation

Validate before calling

# before pushing a title change, confirm the window still exists
wid=$(wezterm cli list --format json | jq -r '.[].window_id' | grep -xF "$WID") || exit 0
wezterm cli set-window-title --window-id "$wid" 'my title'

Try / catch

Wrap the CLI call; if stderr matches /no such window/, treat as a benign lost race (log, exit 0) rather than failing the script.

Prevention

When it happens

Trigger: A GUI or CLI client sends WindowTitleChanged{window_id, title} after that window was closed on the server; the client is connected to a different mux instance (different unix socket) than the one hosting the window; or the mux server restarted and reallocated ids.

Common situations: Running `wezterm cli set-window-title --window-id N` where N came from a stale `wezterm cli list` capture; a long-lived script whose cached window ids outlive their windows; WEZTERM_UNIX_SOCKET pointing at a different server than the window belongs to.

Related errors


AI-assisted analysis of wezterm/wezterm@08e5e0afc6 (2026-08-20). Data as JSON: /api/errors/7b2a49f04d40c5d1. Report an issue: GitHub.