Skip to content

Conversation

@Aarushsr12
Copy link
Contributor

@Aarushsr12 Aarushsr12 commented Jan 9, 2026

Summary by CodeRabbit

  • Bug Fixes
    • Fixed an issue where duplicate listeners could accumulate during hot reloads or rebuilds, preventing requests from being processed multiple times.

✏️ Tip: You can customize this high-level summary in your review settings.

@linear
Copy link

linear bot commented Jan 9, 2026

@coderabbitai
Copy link

coderabbitai bot commented Jan 9, 2026

Walkthrough

The change modifies the exposeMethodOverIPC function in src/renderer/lib/RPCServiceOverIPC.ts to add a pre-listener cleanup step. Before attaching a new listener to the generated channel, the function now removes all existing listeners for that channel. This prevents duplicate listeners from accumulating across hot reloads or multiple builds. No exported method signatures or public API surface areas are affected.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly addresses the main change: removing duplicate listener registration in the IPC service to prevent issues during hot reloads.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/renderer/lib/RPCServiceOverIPC.ts (1)

26-73: Optional: Consider a method registry pattern for future robustness.

While the current fix is effective, you might consider tracking which methods have already been exposed to prevent re-registration entirely:

private exposedMethods = new Set<string>();

protected exposeMethodOverIPC(
  exposedMethodName: string,
  method: (..._args: any[]) => Promise<any>
) {
  const channelName = `${this.RPC_CHANNEL_PREFIX}${exposedMethodName}`;
  
  // Skip if already exposed
  if (this.exposedMethods.has(channelName)) {
    console.warn(`Method ${exposedMethodName} already exposed, skipping re-registration`);
    return;
  }
  
  this.exposedMethods.add(channelName);
  
  ipcRenderer.on(channelName, async (_event, args) => {
    // ... rest of implementation
  });
}

This would make it explicit which methods are registered and prevent any accidental re-registration, though the current approach using removeAllListeners is simpler and works well.

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 56d9654 and 7c7f625.

📒 Files selected for processing (1)
  • src/renderer/lib/RPCServiceOverIPC.ts
🔇 Additional comments (1)
src/renderer/lib/RPCServiceOverIPC.ts (1)

32-36: Effective fix for duplicate listener accumulation.

The pre-listener cleanup correctly prevents duplicate listeners from accumulating during hot reloads or repeated initialization. The removeAllListeners call ensures exactly one active listener per channel, which is the correct behavior for this request-response pattern.

No channel name collisions exist with other code. RPC services use the ${serviceName}-${methodName} pattern (e.g., "FsManagerRPCService-readDir"), while all other listeners in the codebase use completely distinct hardcoded channel names like "start-proxy-server", "save-root-cert", etc. The fix is safe and can be approved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants