Repository navigation
fix: system proxy refresh - #8535
Conversation
RESOLVED pr conversations ADD test cases and os specific test casess REVERTE comment removed for windows refetch refactor: remove redundant afterEach cleanup in shell-env-proxy-refresh tests RENAME the test file and add more test for wider coverage among the test cases test: add integration tests for refreshShellEnvProxyVars delete: remove outdated system proxy integration test file fix: enhance proxy variable restoration on shell-env subprocess failure fix: implement timeout for shellEnv to prevent hanging on misconfigured shells feat: add refreshShellEnvProxyVars function to shell-env-state.ts and update shell environment initialization logic refactor: simplify shell environment refresh and update system proxy integration refactor: implement withTimeout utility for shell environment operations to prevent indefinite hangs
…vars from shell config
0d11517 to
f6e3172
Compare
There was a problem hiding this comment.
Pull request overview
This PR updates Bruno’s Electron system-proxy refresh behavior so a “refresh” re-reads proxy-related environment variables from the user’s login shell (instead of relying on stale process.env values), and exposes fetchShellEnv() from @usebruno/requests to support that flow.
Changes:
- Exported
fetchShellEnv()frombruno-requestsand adjusted its failure semantics to returnnull(callers can distinguish failure from an empty env). - Added shell proxy env var refresh logic + timeout handling to the Electron system proxy store when
fetchSystemProxy({ refresh: true })is used. - Added Jest coverage for env var refresh, removal, Windows no-op behavior, and timeout fallback.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| packages/bruno-requests/src/utils/shell-env.ts | Exports fetchShellEnv() and makes shell-fetch failures explicit via null, with initializeShellEnv() handling that case. |
| packages/bruno-requests/src/index.ts | Re-exports fetchShellEnv from the package entrypoint for external consumers (Electron store). |
| packages/bruno-electron/src/store/system-proxy.js | On refresh, clears/reloads proxy env vars from shell (with timeout) before calling getSystemProxy(). |
| packages/bruno-electron/src/store/tests/system-proxy.spec.js | Adds regression tests validating refresh behavior, failure fallback, Windows behavior, and timeout restoration. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
WalkthroughThis PR adds shell-env proxy synchronization: ChangesShell env proxy refresh
Estimated code review effort: 3 (Moderate) | ~25 minutes Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/bruno-electron/src/store/system-proxy.js (1)
12-38: 🩺 Stability & Availability | 🔵 TrivialOrphaned subprocess on timeout — known trade-off worth documenting.
When the 60s timeout fires,
fetchShellEnv()is still pending. Theshell-envlibrary spawns a child process (e.g.,$SHELL -i -c 'env') that won't be cancelled or cleaned up. The timeout correctly prevents the caller from hanging, but the orphaned process persists until it exits naturally or the app closes. Sinceshell-envdoesn't expose cancellation, consider adding a brief inline note near the timeout logic so future maintainers understand this is an accepted limitation, not an oversight.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/bruno-electron/src/store/system-proxy.js` around lines 12 - 38, The timeout path in refreshShellEnvProxyVars leaves the fetchShellEnv child process running, so add a brief inline note near the Promise.race timeout logic explaining that shell-env has no cancellation support and the orphaned subprocess is an accepted limitation. Keep the comment close to the timeout handling in refreshShellEnvProxyVars so future maintainers understand why no cleanup is attempted when result is null.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@packages/bruno-electron/src/store/system-proxy.js`:
- Around line 12-38: The timeout path in refreshShellEnvProxyVars leaves the
fetchShellEnv child process running, so add a brief inline note near the
Promise.race timeout logic explaining that shell-env has no cancellation support
and the orphaned subprocess is an accepted limitation. Keep the comment close to
the timeout handling in refreshShellEnvProxyVars so future maintainers
understand why no cleanup is attempted when result is null.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: f9a29c4a-61af-4655-b74e-6179866b4638
📒 Files selected for processing (4)
packages/bruno-electron/src/store/system-proxy.jspackages/bruno-electron/src/store/tests/system-proxy.spec.jspackages/bruno-requests/src/index.tspackages/bruno-requests/src/utils/shell-env.ts
Description
Layered on #8159 to move to
bruno-electronContribution Checklist:
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
New Features
Bug Fixes