-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
fix(electron): port-in-use dialog shown when opening a new window | #7595
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
Conversation
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.
Code Review
This pull request refactors the error handling for EADDRINUSE to prevent showing a 'port in use' dialog when opening a new window or activating an existing one. The change simplifies the conditional logic by combining nested if statements into a single if-else block, which improves code clarity and maintainability. Additionally, it updates a loose equality check (==) to a strict one (===), which is a good practice. The fix appears correct and makes the code easier to understand. I have one suggestion to further improve readability.
| console.error(message); | ||
| process.exit(1); | ||
| } | ||
| if ("code" in error && error.code === "EADDRINUSE" && (process.argv.includes("--new-window") || !app.requestSingleInstanceLock())) { |
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.
The condition for this if statement is quite long and combines multiple checks. To improve readability and make the code more self-documenting, you could extract this logic into a helper function. For example, a function named isSecondInstanceLaunch would make the intent of this conditional block immediately clear.
Summary of ChangesHello @SiriusXT, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request resolves an issue where an erroneous 'port in use' dialog would appear when users attempted to open a new application window or activate an existing one. The changes refine the server's error handling to correctly identify these scenarios and suppress the dialog, ensuring a smoother user experience by either opening a new window directly or focusing on the existing instance without interruption. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
Before fix: When opening a new window from the taskbar or trying to activate an existing window, a “port in use” dialog would pop up.
After fix: A new window is opened directly or the existing window is activated without showing the window.