-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
fix: prevent crash when closing window with pending async calls #4435
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: v3-alpha
Are you sure you want to change the base?
Conversation
- Add messageProcessor field to App struct to store MessageProcessor instance - Implement CancelWindowCalls method to cancel pending async calls for a window - Track window calls in MessageProcessor with windowCalls map - Call CancelWindowCalls in window destroy() method to prevent crashes - Add safety checks for destroyed windows in CallError and CallResponse - Update issue-4353 test and example to use correct Wails v3 APIs Fixes #4353 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
WalkthroughThis change implements a fix for a crash that occurred when closing a window with pending asynchronous Go-bound function calls. It introduces per-window tracking and cancellation of running async calls, ensures proper cleanup during window destruction, and adds safety checks to prevent JavaScript execution on destroyed windows. The changelog is updated to reflect this fix. Changes
Sequence Diagram(s)sequenceDiagram
participant JS as JavaScript
participant App as App
participant MP as MessageProcessor
participant Win as WebviewWindow
JS->>App: Async Go-bound call (with windowID)
App->>MP: Register running call (windowID, callID)
Note over MP: Track call under windowID
JS->>Win: User closes window
Win->>MP: CancelWindowCalls(windowID)
MP->>MP: Cancel all running calls for windowID
MP->>App: Remove call tracking
MP->>Win: (If call completes after window closed)
Win->>Win: Check if destroyed<br/>Skip JS execution if destroyed
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~40 minutes Assessment against linked issues
Assessment against linked issues: Out-of-scope changesNo out-of-scope changes detected. Suggested labels
Poem
Note ⚡️ Unit Test Generation is now available in beta!Learn more here, or try it out under "Finishing Touches" below. 📜 Recent review detailsConfiguration used: .coderabbit.yaml 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (3)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
Deploying wails with
|
| Latest commit: |
54ac2c3
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://8a1e5f13.wails.pages.dev |
| Branch Preview URL: | https://v3-alpha-bugfix-issue-4353.wails.pages.dev |
|



Summary
This PR fixes a crash that occurs when closing a window while there are pending async Go-bound function calls.
Root Cause
When a window is closed while async Go method calls are still pending, the application crashes because:
messageProcessorwas created but never stored as a field on the App structFix
messageProcessorfield to the App struct to store the MessageProcessor instanceCancelWindowCallsmethod in MessageProcessor to track and cancel pending calls per windowCancelWindowCallsin the window'sdestroy()methodTesting
Updated the issue-4353 test and example to use the correct Wails v3 APIs (they were using v2-style APIs).
To test:
v3/examples/issue-4353/Fixes #4353
🤖 Generated with Claude Code
Summary by CodeRabbit
Bug Fixes
Improvements