-
Notifications
You must be signed in to change notification settings - Fork 45
[ONCALL-187] logs: debug logs for no-proxy cx issue #245
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: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,7 +13,10 @@ import startHelperServer, { stopHelperServer } from "../startHelperServer"; | |
| import logger from "utils/logger"; | ||
| import { getDefaultProxyPort } from "../storage/cacheUtils"; | ||
| import { handleCARegeneration } from "../apps/os/ca/utils"; | ||
| import { startHelperSocketServer, stopHelperSocketServer } from "../helperSocketServer"; | ||
| import { | ||
| startHelperSocketServer, | ||
| stopHelperSocketServer, | ||
| } from "../helperSocketServer"; | ||
| import portfinder from "portfinder"; | ||
| import LoggerService from "renderer/lib/proxy-interface/loggerService"; | ||
| import { addShutdownHandler } from "../shutdown"; | ||
|
|
@@ -47,13 +50,24 @@ function startProxyFromModule(PROXY_PORT: number) { | |
| RQProxyProvider.createInstance( | ||
| proxyConfig, | ||
| new RulesDataSource(), | ||
| new LoggerService(), | ||
| new LoggerService() | ||
| ); | ||
| window.proxy = RQProxyProvider.getInstance().proxy; | ||
| console.log("DEBUG:", "Proxy assigned to window object"); | ||
| } | ||
|
|
||
| export function stopProxyServer() { | ||
| if(window.proxy) { | ||
| // on startup window.proxy comes undefined | ||
| // but if refreshed or some earlier proxy was there it will show the proxy object | ||
| console.log( | ||
| "DEBUG:", | ||
| `onStartup window.proxy is undefined, else not: ${window.proxy}` | ||
| ); | ||
| if (window.proxy) { | ||
| console.log( | ||
| "DEBUG:", | ||
| `onRefresh window.proxy will be there: ${window.proxy}` | ||
| ); | ||
| window.proxy.close(); | ||
| } | ||
| } | ||
|
|
@@ -65,6 +79,7 @@ export default async function startProxyServer( | |
| ): Promise<IStartProxyResult> { | ||
| // Check if proxy is already listening. If so, close it | ||
| try { | ||
| console.log("DEBUG:", "stopProxyServerCalled"); | ||
| stopProxyServer(); | ||
| logger.log("A proxy server was closed"); | ||
| } catch (error) { | ||
|
|
@@ -74,6 +89,8 @@ export default async function startProxyServer( | |
| const proxyIp = ip()!; | ||
| const targetPort = proxyPort || getDefaultProxyPort(); | ||
|
|
||
| console.log(`DEBUG: ${proxyIp} ${targetPort}`); | ||
|
|
||
| const result: IStartProxyResult = { | ||
| success: true, | ||
| port: targetPort, | ||
|
|
@@ -82,7 +99,9 @@ export default async function startProxyServer( | |
|
|
||
| // start the proxy server | ||
| const FINAL_PROXY_PORT = await getNextAvailablePort(targetPort); | ||
| console.log("DEBUG: Is FINAL_PROXY_PORT is available", FINAL_PROXY_PORT); | ||
| if (!FINAL_PROXY_PORT) { | ||
| console.log("DEBUG: returning success as false"); | ||
| result.success = false; | ||
| return result; | ||
| } | ||
|
|
@@ -94,13 +113,18 @@ export default async function startProxyServer( | |
|
|
||
| // start the helper server if not already running | ||
| if (shouldStartHelperServer) { | ||
| // No proxy comes for the case when there is success is false in result | ||
| console.log("DEBUG:", "starting up the helper server"); | ||
| const HELPER_SERVER_PORT = await getNextAvailablePort( | ||
| DEFAULT_HELPER_SERVER_PORT | ||
| ); | ||
|
|
||
| result.helperServerPort = HELPER_SERVER_PORT; | ||
|
|
||
| if (!HELPER_SERVER_PORT) { | ||
| console.log( | ||
| "DEBUG: returning success as false as no helper server port available" | ||
| ); | ||
| result.success = false; | ||
| return result; | ||
| } | ||
|
|
@@ -111,15 +135,19 @@ export default async function startProxyServer( | |
| port: DEFAULT_SOCKET_SERVER_PORT, | ||
| stopPort: DEFAULT_SOCKET_SERVER_PORT + 4, // 5 ports for fallback | ||
| }); | ||
| console.log( | ||
| "DEBUG:", | ||
| `${HELPER_SOCKET_SERVER_PORT} HELPER_SOCKET_SERVER_PORT is available` | ||
| ); | ||
| startHelperSocketServer(HELPER_SOCKET_SERVER_PORT); | ||
|
|
||
| // fix-me: this does not remove existing handlers when restarting. | ||
| // fix-me: this does not remove existing handlers when restarting. | ||
| // For now that doesn't have side effects | ||
| addShutdownHandler(() => { | ||
| stopProxyServer(); | ||
| stopHelperServer(); | ||
| stopHelperSocketServer(); | ||
| }) | ||
| }); | ||
|
Comment on lines
+144
to
+150
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Potential memory leak from accumulating shutdown handlers. The comment on line 142 correctly identifies that Consider one of these approaches:
Would you like me to generate a solution that prevents handler accumulation? 🤖 Prompt for AI Agents |
||
|
|
||
| return result; | ||
| } | ||
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.
🧩 Analysis chain
🏁 Script executed:
# First, find the file and examine its size wc -l src/main/actions/startBackgroundProcess.jsRepository: requestly/requestly-desktop-app
Length of output: 120
🏁 Script executed:
Repository: requestly/requestly-desktop-app
Length of output: 57
🏁 Script executed:
# Read the entire startBackgroundProcess.js file cat -n src/main/actions/startBackgroundProcess.jsRepository: requestly/requestly-desktop-app
Length of output: 3609
🏁 Script executed:
Repository: requestly/requestly-desktop-app
Length of output: 937
🏁 Script executed:
Repository: requestly/requestly-desktop-app
Length of output: 648
🏁 Script executed:
Repository: requestly/requestly-desktop-app
Length of output: 167
🏁 Script executed:
# Check if there's a git history for this file to understand if this is a recent change git log --oneline -10 src/main/actions/startBackgroundProcess.jsRepository: requestly/requestly-desktop-app
Length of output: 100
🏁 Script executed:
Repository: requestly/requestly-desktop-app
Length of output: 170
Remove the early return or ensure global.backgroundWindow and initialization state are properly managed.
The early return when
backgroundWindowalready exists (lines 55-56) is problematic. If this function is called a second time when a window already exists:global.backgroundWindowis never assigned (line 59 is skipped), leaving it undefined or staleinitPrimaryStorage.jsandcleanup.jsthat checksif (global.backgroundWindow)will fail silentlyresolve(true)is called immediately rather than waiting for the window to finish loadingThe log message "Cancelling" suggests this is a guard against multiple simultaneous calls, but the guard is incomplete. Either complete the full initialization sequence even when the window exists, or ensure that
global.backgroundWindowand other global state are already set from the previous call before returning early.🤖 Prompt for AI Agents