Skip to content

fix: update system proxy fetching to use finally#7652

Merged
bijin-bruno merged 2 commits intousebruno:mainfrom
sid-bruno:fix/wg-move-to-finally
Apr 1, 2026
Merged

fix: update system proxy fetching to use finally#7652
bijin-bruno merged 2 commits intousebruno:mainfrom
sid-bruno:fix/wg-move-to-finally

Conversation

@sid-bruno
Copy link
Copy Markdown
Collaborator

@sid-bruno sid-bruno commented Apr 1, 2026

Description

Move the fetchSystemProxy to a finally block in case the shellenv sync fails after a timeout, it would still make sense for whatever proxy information is available to be picked up.

Contribution Checklist:

  • I've used AI significantly to create this pull request
  • The pull request only addresses one issue or adds one feature.
  • The pull request does not introduce any breaking changes
  • I have added screenshots or gifs to help explain the change if applicable.
  • I have read the contribution guidelines.
  • Create an issue and link to the pull request.

Note: Keeping the PR small and focused helps make it easier to review and merge. If you have multiple changes you want to make, please consider submitting them as separate pull requests.

Publishing to New Package Managers

Please see here for more information.

Summary by CodeRabbit

  • Bug Fixes

    • System proxy detection now runs during app startup regardless of shell environment initialization outcome, improving reliability of proxy configuration. Added a warning log when shell environment initialization fails.
  • Chores

    • Added a type annotation to the shell environment promise variable to improve code clarity and maintainability.

Copilot AI review requested due to automatic review settings April 1, 2026 17:06
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 1, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: c7cc874c-d270-4f81-b0ce-c7c1d9d8dc00

📥 Commits

Reviewing files that changed from the base of the PR and between 2364c30 and a6b658b.

📒 Files selected for processing (1)
  • packages/bruno-electron/src/index.js
✅ Files skipped from review due to trivial changes (1)
  • packages/bruno-electron/src/index.js

Walkthrough

System proxy cache initialization in the Electron app now always runs fetchSystemProxy() via a waitForShellEnv().catch(...).finally(...) chain; failures initializing the shell env are now logged with console.warn('Shell env init failed:', err). A JSDoc type annotation was added for the module _promise in shell-env-state.

Changes

Cohort / File(s) Summary
Proxy Initialization Flow
packages/bruno-electron/src/index.js
Replaced waitForShellEnv().then(...) with waitForShellEnv().catch(...).finally(...); fetchSystemProxy() now always runs in finally; added console.warn('Shell env init failed:', err) on shell init rejection; retained existing warning for fetchSystemProxy() failure.
Shell Environment State
packages/bruno-electron/src/store/shell-env-state.js
Added JSDoc type annotation marking module _promise as `null

Sequence Diagram(s)

(Skipped — changes are localized and do not introduce a multi-component new control flow requiring visualization.)

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested labels

size/XS

Suggested reviewers

  • helloanoop
  • lohit-bruno
  • naman-bruno
  • bijin-bruno

Poem

🐇 In startup's hush the shell may sigh,

but fetch the proxy, come low or high,
a warning whispered, then the call—
it runs at last, no matter all,
the app wakes steady, standing by ✨

🚥 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 accurately describes the main change: moving fetchSystemProxy() into a finally block for more robust proxy handling.
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 unit tests (beta)
  • Create PR with 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.

❤️ Share

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

Copy link
Copy Markdown
Contributor

Copilot AI left a 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 the system proxy cache is fetched even if shell environment initialization fails (e.g., due to a timeout), by moving the proxy fetch into a finally handler.

Changes:

  • Add a JSDoc type annotation for the internal shell env initialization promise.
  • Update startup flow to call fetchSystemProxy() in a .finally(...) after waitForShellEnv() settles (resolve or reject).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
packages/bruno-electron/src/store/shell-env-state.js Adds a JSDoc type for the memoized shell env init promise.
packages/bruno-electron/src/index.js Switches proxy cache initialization to run in a finally so it executes even when shell env init fails.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Contributor

@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: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/bruno-electron/src/index.js`:
- Around line 205-215: The call to waitForShellEnv() can reject (e.g., timeout)
and currently its rejection is unhandled; modify the chain around
waitForShellEnv().finally(... ) to add a .catch() handler on waitForShellEnv()
(or on the full promise chain) so rejections are swallowed or logged; ensure you
still call fetchSystemProxy() in finally and add a clear log inside the .catch()
referencing waitForShellEnv to report the error.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 99c41fc9-bb1e-4a9d-8d88-813e6ce3c22a

📥 Commits

Reviewing files that changed from the base of the PR and between c7ebe25 and 2364c30.

📒 Files selected for processing (2)
  • packages/bruno-electron/src/index.js
  • packages/bruno-electron/src/store/shell-env-state.js

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@bijin-bruno bijin-bruno merged commit ce87289 into usebruno:main Apr 1, 2026
12 checks passed
lohit-bruno pushed a commit to lohit-bruno/bruno that referenced this pull request Apr 1, 2026
* fix: update system proxy fetching to use finally for improved reliability

* Update packages/bruno-electron/src/index.js

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
bijin-bruno pushed a commit that referenced this pull request Apr 2, 2026
* fix: update system proxy fetching to use finally (#7652)

* fix: update system proxy fetching to use finally for improved reliability

* Update packages/bruno-electron/src/index.js

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* fix: allow file selection in multipart form without entering a key first (#7640)

* fix: close previous SSE connection before sending new request

When resending an SSE (Server-Sent Events) request using Cmd+Enter,
the previous connection was not being closed, causing connection leaks.

Changes:
- Add SSE cancellation logic to sendRequest action - checks for running
  stream and cancels it before sending new request
- Add return to cancelRequest action to make it properly chainable
- Simplify RequestTabPanel by removing duplicate cancel logic (now
  handled centrally in sendRequest)
- Add SSE endpoints to test server for e2e testing
- Add Playwright e2e test to verify SSE connection cancellation

* fix: address PR review feedback for SSE connection cancellation

- Use platform-aware modifier (Meta on macOS, Control on Linux/Windows)
  instead of hardcoded Meta+Enter for cross-platform CI compatibility
- Replace waitForTimeout with expect.poll for deterministic assertions
- Remove dead try/catch around cancelRequest (errors already swallowed
  by cancelRequest's internal .catch)

* fix: updated the test to check of connectionIds

---------

Co-authored-by: Sid <siddharth@usebruno.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Pooja <pooja@usebruno.com>
Co-authored-by: Chirag Chandrashekhar <cchirag85@gmail.com>
lohit-bruno pushed a commit that referenced this pull request Apr 3, 2026
* fix: update system proxy fetching to use finally for improved reliability

* Update packages/bruno-electron/src/index.js

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants