lencx/ChatGPT · critical
[core:window] Failed to build window
Error message
[core:window] Failed to build window
What it means
Panic from WindowBuilder::build() (tauri::WebviewWindowBuilder/WindowBuilder) returning Err. build() creates the OS-native window and registers it under the label "core"; it fails when the label is already taken, the event loop is gone, or the platform rejects window creation (display server error, invalid theme/size params). The .expect() then panics inside the tauri::async_runtime::spawn task, so no window ever appears.
Source
Thrown at src-tauri/src/core/setup.rs:48
async move {
let mut core_window = WindowBuilder::new(&handle, "core").title("ChatGPT");
#[cfg(target_os = "macos")]
{
core_window = core_window
.title_bar_style(TitleBarStyle::Overlay)
.hidden_title(true);
}
core_window = core_window
.resizable(true)
.inner_size(800.0, 600.0)
.min_inner_size(300.0, 200.0)
.theme(Some(AppConf::get_theme(&handle)));
let core_window = core_window
.build()
.expect("[core:window] Failed to build window");
let win_size = core_window
.inner_size()
.expect("[core:window] Failed to get window size");
// Wrap the window in Arc<Mutex<_>> to manage ownership across threads
let window = Arc::new(Mutex::new(core_window));
let main_view =
WebviewBuilder::new("main", WebviewUrl::App("https://chatgpt.com".into()))
.auto_resize()
.on_download({
let app_handle = handle.clone();
let download_path = Arc::new(Mutex::new(PathBuf::new()));
move |_, event| {
match event {
DownloadEvent::Requested { destination, .. } => {
let download_dir = app_handle
.path()View on GitHub (pinned to a6de9a8b61)
Solutions
- Make the label unique or bail out if a window labeled "core" already exists (check handle.get_webview_window("core") before building)
- Replace .expect() with match/if-let on the Err and log the underlying error (it carries the real cause, e.g. "label already exists" or display error)
- Ensure the single-instance plugin (tauri-plugin-single-instance) is registered so a second launch shows the first window instead of re-running setup
- On Linux, verify the session has a working display (echo $XDG_SESSION_TYPE, run under X11/XWayland if the compositor is unstable)
Example fix
// before
let core_window = core_window
.build()
.expect("[core:window] Failed to build window");
// after
let core_window = match core_window.build() {
Ok(w) => w,
Err(e) => {
eprintln!("[core:window] Failed to build window: {e}");
return;
}
}; Defensive patterns
Strategy: try-catch
Validate before calling
// before building: ensure the label is free
if handle.get_webview_window("core").is_some() {
eprintln!("[core:window] label 'core' already exists; skipping build");
return;
} Type guard
fn core_window_absent(handle: &tauri::AppHandle) -> bool {
handle.get_webview_window("core").is_none()
} Try / catch
let core_window = match core_window.build() {
Ok(w) => w,
Err(e) => {
eprintln!("[core:window] Failed to build window: {e}");
return;
}
}; Prevention
- Register tauri-plugin-single-instance so setup never runs twice
- Keep window labels in one constant/module to avoid duplicates
- Never .expect() on build(); propagate or log-and-return from the async task
When it happens
Trigger: Calling WindowBuilder::new(&handle, "core")...build() twice with the same label (double init, hot-reload in `tauri dev` re-running setup, single-instance plugin disabled and a second instance starting); running on Linux under a broken display session (XDG_SESSION_TYPE unset, Wayland compositor crash); passing a theme value the platform cannot honor.
Common situations: Developers adding a second window in setup and reusing the label "core"; enabling the single-instance plugin incorrectly so a second app instance runs setup again; Linux CI/headless environments with no display; upgrading tauri v1->v2 where builder APIs changed and setup code is invoked from both the old and new hook.
Related errors
- [core:window] Failed to get window size
- error while running lencx/ChatGPT application
- [view:download] Failed to get download directory
- [view:main] Failed to get webview window
- [view:titlebar] Failed to get webview window
AI-assisted analysis of lencx/ChatGPT@a6de9a8b61 (2026-08-16).
Data as JSON: /api/errors/deb2fca2f19906de.
Report an issue: GitHub.