Skip to content

openWindows() returns undefined on Linux when any single window fails #199

Description

@RealmX1

Description

On Linux systems, the openWindows() function returns undefined when it fails to retrieve information for any single window, even if other windows are accessible. This causes a complete loss of window tracking functionality.

Current Behavior

When openWindows() encounters a window it cannot access (zombie window, permission issues, etc.), the entire function returns undefined, losing all window information.

Expected Behavior

The function should skip inaccessible windows and return information for all windows it can successfully access, similar to how the Windows implementation works.

Steps to Reproduce

  1. Use get-windows on a Linux system with X11
  2. Have a process that creates a window and then terminates abnormally (leaving a zombie window ID in X11)
  3. Call openWindows()
  4. The function returns undefined instead of a list of accessible windows

System Information

  • OS: Linux (Ubuntu 22.04)
  • Window System: X11
  • get-windows version: 9.2.0
  • Node.js version: 18+

Root Cause

The issue is in lib/linux.js at line 162:

for await (const windowId of windowsIds) {
    openWindows.push(await getWindowInformation(Number.parseInt(windowId, 16)));
}

When getWindowInformation() throws an error for any window, the entire openWindows() function fails.

Impact

  • Users lose all window tracking capability when even one window is inaccessible
  • The issue persists until system restart (zombie windows remain in X11)
  • Affects any application using get-windows for window management on Linux

Proposed Solution

Add try-catch blocks around individual window information retrieval (see PR #198).

Related

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