jlcodes99/cockpit-tools · warning

[Window] startDragging failed:

Error message

[Window] startDragging failed:

What it means

Tauri's `startDragging()` on the current WebviewWindow asks the native window manager to begin an OS-level drag of the window. It fails when the runtime or platform refuses the drag operation (window not found, permission/decoration constraints, or the webview already has another operation in flight). The app only logs a warning since a failed drag is non-fatal.

Source

Thrown at src/App.tsx:3582

        }
        console.info('[ExternalImport][App] 启动时读取到待处理导入 payload');
        void handleExternalProviderImportRawPayload(payload);
      })
      .catch((error) => {
        console.warn('[ExternalImport] 读取待处理导入请求失败:', error);
      });
    return () => {
      canceled = true;
    };
  }, [handleExternalProviderImportRawPayload]);

  // 窗口拖拽处理
  const handleDragStart = (event: ReactMouseEvent<HTMLDivElement>) => {
    if (event.button !== 0) {
      return;
    }
    void getCurrentWindow().startDragging().catch((error) => {
      console.warn('[Window] startDragging failed:', error);
    });
  };

  useEffect(() => {
    const handleRequestNavigate = (e: Event) => {
      const custom = e as CustomEvent<Page>;
      if (custom.detail) {
        setPage(custom.detail);
      }
    };
    window.addEventListener('app-request-navigate', handleRequestNavigate as EventListener);
    return () => {
      window.removeEventListener('app-request-navigate', handleRequestNavigate as EventListener);
    };
  }, []);

  useEffect(() => {
    const handleOpenPlatformLayout = (e: Event) => {

View on GitHub (pinned to 1ed8b77992)

Solutions

  1. Check the window still exists before dragging: guard with `await getCurrentWindow().isVisible()` or wrap in a try/catch that ignores NotFound errors.
  2. Verify the Tauri version and platform: on Linux/Wayland programmatic dragging may be unsupported; test on the target platform.
  3. Ensure `decorations: false` window config matches the drag-region setup and no overlaying element intercepts the event with a conflicting handler.
  4. If the error is intermittent during shutdown, debounce or skip drag requests when a close is already in progress.

Example fix

// before
void getCurrentWindow().startDragging().catch((error) => {
  console.warn('[Window] startDragging failed:', error);
});
// after
void getCurrentWindow()
  .startDragging()
  .catch((error) => {
    if (String(error).includes('window not found')) return;
    console.warn('[Window] startDragging failed:', error);
  });
Defensive patterns

Strategy: try-catch

Validate before calling

const win = getCurrentWindow();
if (event.button === 0 && win && document.visibilityState === 'visible') {
  void win.startDragging();
}

Type guard

function isLeftButton(e: ReactMouseEvent): boolean {
  return e.button === 0;
}

Try / catch

try {
  await getCurrentWindow().startDragging();
} catch (error) {
  if (!String(error).includes('window not found')) {
    console.warn('[Window] startDragging failed:', error);
  }
}

Prevention

When it happens

Trigger: User presses the left mouse button (button === 0) on the custom title bar div in MainApp, and `getCurrentWindow().startDragging()` rejects — e.g. the window was closed/minimized mid-call, the platform does not support programmatic drag, or the call races with another window operation.

Common situations: Custom frameless title bars in Tauri apps; rapid clicks during window teardown; Linux/Wayland environments where dragging support differs from Windows/macOS; calling drag on a window handle after the window was destroyed.

Related errors


AI-assisted analysis of jlcodes99/cockpit-tools@1ed8b77992 (2026-09-05). Data as JSON: /api/errors/4c6096c4cff2061c. Report an issue: GitHub.