Fix streamlinear-cli proxy support in cloud environments#1716
Conversation
Node.js built-in fetch (undici) doesn't respect HTTP_PROXY/HTTPS_PROXY env vars by default. Add --use-env-proxy to NODE_OPTIONS when behind an egress proxy, so tools like streamlinear-cli that use bare fetch() work. https://claude.ai/code/session_01JVjfBK5ybYXCqSTQeEV9Hr
There was a problem hiding this comment.
Pull request overview
Updates the worktree initialization hook to improve proxy compatibility for Node-based tooling (notably streamlinear-cli) in cloud environments behind an authenticated egress proxy by enabling Node’s env-proxy support.
Changes:
- Export
NODE_OPTIONSwith--use-env-proxyduring worktree init whenHTTP_PROXYis present. - Persist the proxy-related environment setup by adding
NODE_OPTIONSto the existing shell export block alongsideHEX_CDNand PATH wrapper setup.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughDetects credentialed Changes
Sequence Diagram(s)sequenceDiagram
participant InitScript as Init Script
participant Wrapper as Wrapper / _EXPORT_BLOCK
participant SysProfile as /etc/profile.d/hex-bridge.sh
participant UserRC as ~/.bashrc / ~/.zshenv
participant Node as Node Runtime
InitScript->>InitScript: detect HTTP_PROXY with credentials
alt Node major >= 22 and no --use-env-proxy
InitScript->>InitScript: export NODE_OPTIONS="... --use-env-proxy" (session)
InitScript->>Wrapper: append NODE_OPTIONS stanza to _EXPORT_BLOCK
InitScript->>SysProfile: write/overwrite hex-bridge.sh
InitScript->>UserRC: insert _EXPORT_BLOCK or backfill use-env-proxy case
Wrapper->>Node: wrapper-provided env includes NODE_OPTIONS
else No change
InitScript->>Node: no NODE_OPTIONS modification
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In @.claude/hooks/worktree-init.sh:
- Line 64: The current export that appends "--use-env-proxy" to NODE_OPTIONS
blindly duplicates the flag on repeated sources; change both occurrences of the
export that reference NODE_OPTIONS so they first check whether NODE_OPTIONS
already contains the substring "--use-env-proxy" (e.g., with a shell case or
grep test) and only append " --use-env-proxy" when it is not present, preserving
existing spacing and behavior when NODE_OPTIONS is empty or non-empty.
- Line 64: Guard the NODE_OPTIONS export that adds "--use-env-proxy" by checking
the installed Node version before setting it: parse the Node version from `node
-v` (or `node -p "process.versions.node"`), compare semver and only append
`--use-env-proxy` to NODE_OPTIONS when the runtime is >=22.21.0, >=24.5.0, or
any 25.x; for older Node versions set `NODE_USE_ENV_PROXY=1` instead. Update
both places that export NODE_OPTIONS containing "--use-env-proxy" to use this
version check and fallback to exporting `NODE_USE_ENV_PROXY=1` when the flag is
not supported. Ensure the shell logic preserves existing NODE_OPTIONS content
when appending and is POSIX-compatible.
- Around line 94-95: The install script currently writes the export lines
(export PATH="${WRAPPER_DIR}:${PATH}" and export
NODE_OPTIONS="${NODE_OPTIONS:+${NODE_OPTIONS} }--use-env-proxy"") only when
inserting a new marker, so existing shell config blocks with the old marker are
never rewritten and NODE_OPTIONS isn’t backfilled; update
.claude/hooks/worktree-init.sh to detect both the new and old marker variants in
target files (~/.bashrc, ~/.zshenv, /etc/profile.d/hex-bridge.sh), and when an
old-marker block is found replace/upgrade that block (or inject only the missing
export NODE_OPTIONS line) rather than skipping, ensuring the operation is
idempotent and preserves other user content. Ensure the detection uses the exact
export lines as anchors and that the replacement writes the persisted
NODE_OPTIONS export consistently for upgraded environments.
🪄 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: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 74cdaff4-8b61-4dd9-970b-b1a40f722860
📒 Files selected for processing (1)
.claude/hooks/worktree-init.sh
- Guard NODE_OPTIONS append with `case` to prevent duplication on re-source - Check Node major version >= 22 before setting --use-env-proxy - Always overwrite /etc/profile.d/hex-bridge.sh (file is entirely ours) - Backfill NODE_OPTIONS into existing ~/.bashrc and ~/.zshenv that have the marker but lack the use-env-proxy line https://claude.ai/code/session_01JVjfBK5ybYXCqSTQeEV9Hr
There was a problem hiding this comment.
Actionable comments posted: 1
♻️ Duplicate comments (1)
.claude/hooks/worktree-init.sh (1)
61-73:⚠️ Potential issue | 🟠 MajorTighten the
--use-env-proxyversion gate.The comment says
Node 22.21+, but the live check is onlymajor >= 22, and the persisted_EXPORT_BLOCKdrops the version guard completely. Node's enterprise proxy guide limits--use-env-proxyto v22.21.0 or v24.5.0+, while the CLI docs showNODE_USE_ENV_PROXY=1as the earlier switch on v24.0.0+. Please make both the live export and the persisted block semver-aware instead of persisting the bare flag on unsupported minors. (nodejs.org)Official Node.js docs: which released versions support the `--use-env-proxy` CLI flag, and from which version is `NODE_USE_ENV_PROXY=1` available?Also applies to: 103-104
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.claude/hooks/worktree-init.sh around lines 61 - 73, The script currently only checks _NODE_MAJOR and unconditionally persists --use-env-proxy; change both the live check and the persisted _EXPORT_BLOCK logic to parse the full Node semver (e.g., read process.versions.node into a _NODE_VERSION and split into MAJOR, MINOR, PATCH) and only set or persist "--use-env-proxy" when the version satisfies the Node docs: (MAJOR==22 and MINOR>=21) OR (MAJOR>=24 and (MINOR>5 or (MINOR==5 and PATCH>=0))); additionally, for Node 24.0.0+ prefer using NODE_USE_ENV_PROXY=1 where appropriate instead of the CLI flag; update the conditions that reference _NODE_MAJOR, NODE_OPTIONS, and _EXPORT_BLOCK so the check is semver-aware in both the runtime export and the persisted block.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In @.claude/hooks/worktree-init.sh:
- Around line 103-104: The NODE_OPTIONS proxy stanza is currently placed inside
the rebar3/WRAPPER_DIR-specific branch (around the export PATH and REAL_REBAR3
logic), so when rebar3 is absent the current shell gets fixed but
/etc/profile.d/hex-bridge.sh, ~/.bashrc and ~/.zshenv do not — causing the proxy
fix to vanish in later shells; move the NODE_OPTIONS export (the case ...
--use-env-proxy ... export NODE_OPTIONS logic referencing NODE_OPTIONS) out of
the rebar3/WRAPPER_DIR-specific branch so it always runs, and leave only the
export PATH="${WRAPPER_DIR}:${PATH}" and HEX_CDN/WRAPPER_DIR-related exports
guarded by the REAL_REBAR3 check; apply the same change to the other identical
NODE_OPTIONS blocks later in the file (the repeated stanzas) so NODE_OPTIONS
persistence is hoisted while PATH/HEX_CDN remain conditional.
---
Duplicate comments:
In @.claude/hooks/worktree-init.sh:
- Around line 61-73: The script currently only checks _NODE_MAJOR and
unconditionally persists --use-env-proxy; change both the live check and the
persisted _EXPORT_BLOCK logic to parse the full Node semver (e.g., read
process.versions.node into a _NODE_VERSION and split into MAJOR, MINOR, PATCH)
and only set or persist "--use-env-proxy" when the version satisfies the Node
docs: (MAJOR==22 and MINOR>=21) OR (MAJOR>=24 and (MINOR>5 or (MINOR==5 and
PATCH>=0))); additionally, for Node 24.0.0+ prefer using NODE_USE_ENV_PROXY=1
where appropriate instead of the CLI flag; update the conditions that reference
_NODE_MAJOR, NODE_OPTIONS, and _EXPORT_BLOCK so the check is semver-aware in
both the runtime export and the persisted block.
🪄 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: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 07659ee2-e748-4885-b9e0-9eaa917b01ee
📒 Files selected for processing (1)
.claude/hooks/worktree-init.sh
The NODE_OPTIONS --use-env-proxy persistence was nested inside the rebar3-found branch, so environments without rebar3 wouldn't get the fix persisted to shell configs. Hoist the persistence block (profile.d, bashrc, zshenv) to always run when behind a proxy. https://claude.ai/code/session_01JVjfBK5ybYXCqSTQeEV9Hr
Summary
fetch()(undici) doesn't respectHTTP_PROXY/HTTPS_PROXYenv vars, causingstreamlinear-clito fail withError: fetch failedin cloud environments behind an egress proxy--use-env-proxytoNODE_OPTIONSin the worktree-init hook's proxy setup block (Node 22+ flag)/etc/profile.d/,~/.bashrc,~/.zshenvKey changes
NODE_OPTIONSwith--use-env-proxyin the live session (line 64)_EXPORT_BLOCKfor shell persistence (line 95)HTTP_PROXYguard — only activates in proxy environmentsTest plan
streamlinear-cli searchfails without the fix (Error: fetch failed)streamlinear-cli searchsucceeds with--use-env-proxyNODE_OPTIONSappends correctly when pre-existing options are setSummary by CodeRabbit