fix(linux): handle individual window errors in openWindows#198
Conversation
When a window's information cannot be retrieved (e.g., zombie windows, permission issues), openWindows() now continues processing other windows instead of returning undefined for the entire list. This fixes a critical issue where a single inaccessible window would prevent all window information from being retrieved on Linux systems. The fix adds: - Try-catch blocks around individual getWindowInformation() calls - Debug logging via DEBUG_GET_WINDOWS environment variable - Graceful degradation returning partial window lists - Similar error handling for both async and sync versions This aligns the Linux implementation with the Windows C++ implementation which already handles individual window errors gracefully. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
6a15be8 to
18e904b
Compare
|
Can you try out the latest |
Test Report: Latest main branch on LinuxI've tested the latest main branch with the merged PR on Linux. The fix is working perfectly! 🎉 Test Environment
Comparison ResultsBefore (v9.2.0):
After (latest main):
The error handling is now resilient - individual window failures don't break the entire function. The debug logging also provides great visibility when enabled. Conclusion: The fix works as expected and is ready for release. Thank you for merging this! |
|
I might not have followed all your instructions in PR though. just read it. If you don't want the console.debug logs just remove them. |
|
also, the reason for failed retrieval might be becuase zombie windows in linux which persist in system even after closed. I don't know how that can be addressed. This is just a workaround the problem by adding error handling. but I guess fixing that isn't the responsibility of this package so I dind't bother investigating it. |
Problem
The
openWindows()function on Linux returnsundefinedwhen any single window fails to retrieve information. This causes a complete loss of window tracking functionality even when most windows are accessible.Root Cause
The issue occurs in
lib/linux.jsat line 162 where thefor awaitloop doesn't handle errors for individual windows. WhengetWindowInformation()throws an error for any window (common with zombie windows or permission issues), the entire function fails.Solution
This PR adds try-catch blocks around individual
getWindowInformation()calls, allowing the function to:undefinedwhen no windows can be accessedChanges
openWindows()openWindowsSync()DEBUG_GET_WINDOWSenvironment variableTesting
Test output showing the fix working:
Breaking Changes
None. The function signature and return behavior remain the same for normal operation.
Checklist
This fix aligns the Linux implementation with the Windows C++ implementation, which already handles individual window errors gracefully.
🤖 Generated with Claude Code