-
-
Notifications
You must be signed in to change notification settings - Fork 196
fix(server): Ensure local server closes on terminateApp with forwardingPort #805
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
fix(server): Ensure local server closes on terminateApp with forwardingPort #805
Conversation
|
Thank you. Could you sign the CLA? @GayatriNairAtBrowserstack |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR ensures that the local server is properly closed when terminateApp is called with the forwardingPort capability enabled, preventing port conflicts during subsequent sessions.
- Added logic to check for an existing local server and attempt to close it before proceeding.
- Ensured proper logging of server closure actions.
driver/lib/sessions/ios.ts
Outdated
| if (this.localServer) { | ||
| this.log.info(`Closing existing local server on port ${port}`); | ||
| await new Promise<void>((resolve) => { | ||
| this.localServer?.close(() => { |
Copilot
AI
Jun 13, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider handling potential errors in the close callback by accepting and checking the error parameter (e.g., using a signature like close(err) => { ... }). This ensures that any issues during the closure are properly logged or handled.
| this.localServer?.close(() => { | |
| this.localServer?.close((err) => { | |
| if (err) { | |
| this.log.error(`Error occurred while closing the local server: ${err.message}`); | |
| return resolve(); // Resolve even if there's an error to avoid hanging | |
| } |
done @KazuCocoa |
|
Thank you! Both comments by the Copilot are reasonable. I'll apply them also and merge this PR. |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
|
Thankn you |
This PR addresses an issue where the local server is not properly closed after the terminateApp command is executed when the forwardingPort capability is active. This leads to a subsequent session failure, as Flutter attempts to establish a connection on the same port that was not released.
This fix ensures the local server is correctly terminated, allowing new sessions to start without port conflicts.
Context
Problem: When using the forwardingPort capability, the local server fails to shut down upon terminateApp.
Impact: Any subsequent test session fails because the port is already in use.
Solution: The changes in this PR ensure the server instance is properly closed.
Environment
Flutter Version: 2.15.2
Logs 📝
Passing Session Log :
passingAppiumLogs.txt
without forwardingPort
cap:
Failin Session logs with forwardingPort
failingsession.log
Passing Session with fix
passsingAppiumLogsWithFix.txt