Skip to content

Web/LAN mode renders a blank page: getCurrentWindow() called at module scope #145

Description

@den3110

Summary

In web/LAN mode (pnpm lan), the dashboard renders a blank page. The bundle throws before React can mount.

Console error

Uncaught TypeError: Cannot read properties of undefined (reading 'metadata')
    at Sr (main-*.js)

Cause

src/App.tsx:63 calls getCurrentWindow() at module scope:

const appWindow = getCurrentWindow();

getCurrentWindow() dereferences window.__TAURI_INTERNALS__.metadata.currentWindow.label, which only exists inside the Tauri shell. In a plain browser __TAURI_INTERNALS__ is undefined, so module evaluation throws and nothing renders.

Every one of the 7 call sites is already guarded with isTauriRuntime() — only the declaration itself is not.

Reproduce

pnpm lan
# open http://localhost:3210 -> blank page

Suggested fix

Resolve it lazily so the module can evaluate outside Tauri:

let appWindowRef: ReturnType<typeof getCurrentWindow> | null = null;
const appWindow = () => (appWindowRef ??= getCurrentWindow());

then update the 7 call sites to appWindow()..

Related: the minimize/maximize/close buttons at src/App.tsx:1285 are gated only on !isMacOs, so they render in the browser too and throw when clicked. They could take an isTauriRuntime() check as well.

Version: v0.2.12

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions