Skip to content

Fix streamlinear-cli proxy support in cloud environments#1716

Merged
jamesc merged 3 commits intomainfrom
claude/fix-streamlinear-proxy-z5wmJ
Mar 28, 2026
Merged

Fix streamlinear-cli proxy support in cloud environments#1716
jamesc merged 3 commits intomainfrom
claude/fix-streamlinear-proxy-z5wmJ

Conversation

@jamesc
Copy link
Copy Markdown
Owner

@jamesc jamesc commented Mar 28, 2026

Summary

  • Node.js built-in fetch() (undici) doesn't respect HTTP_PROXY/HTTPS_PROXY env vars, causing streamlinear-cli to fail with Error: fetch failed in cloud environments behind an egress proxy
  • Add --use-env-proxy to NODE_OPTIONS in the worktree-init hook's proxy setup block (Node 22+ flag)
  • Persisted via the same 3 methods used for hex-bridge: /etc/profile.d/, ~/.bashrc, ~/.zshenv

Key changes

  • Export NODE_OPTIONS with --use-env-proxy in the live session (line 64)
  • Include it in the _EXPORT_BLOCK for shell persistence (line 95)
  • Scoped inside existing HTTP_PROXY guard — only activates in proxy environments

Test plan

  • Verified streamlinear-cli search fails without the fix (Error: fetch failed)
  • Verified streamlinear-cli search succeeds with --use-env-proxy
  • Verified NODE_OPTIONS appends correctly when pre-existing options are set
  • Confirmed idempotent — safe if hook runs multiple times

Summary by CodeRabbit

  • Chores
    • Ensures Node 22+ processes respect authenticated HTTP proxy settings by applying the env-based proxy flag immediately and persisting it into shell startup environments.
  • Bug Fixes
    • Improves persistence and backfill of the proxy export across system and user shell startup files so the proxy flag is consistently present after setup.

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
Copilot AI review requested due to automatic review settings March 28, 2026 10:13
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

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_OPTIONS with --use-env-proxy during worktree init when HTTP_PROXY is present.
  • Persist the proxy-related environment setup by adding NODE_OPTIONS to the existing shell export block alongside HEX_CDN and PATH wrapper setup.

Comment thread .claude/hooks/worktree-init.sh Outdated
Comment thread .claude/hooks/worktree-init.sh Outdated
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 28, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c60d298c-6a76-45ed-8ea5-2ebcb8336f70

📥 Commits

Reviewing files that changed from the base of the PR and between df651e3 and 150190f.

📒 Files selected for processing (1)
  • .claude/hooks/worktree-init.sh
🚧 Files skipped from review as they are similar to previous changes (1)
  • .claude/hooks/worktree-init.sh

📝 Walkthrough

Walkthrough

Detects credentialed HTTP_PROXY and, for Node >=22 when --use-env-proxy is missing, adds --use-env-proxy to NODE_OPTIONS in-session, into the wrapper's _EXPORT_BLOCK, and persists it by writing /etc/profile.d/hex-bridge.sh and updating or backfilling ~/.bashrc and ~/.zshenv.

Changes

Cohort / File(s) Summary
Proxy export logic
.claude/hooks/worktree-init.sh
Detects credentialed HTTP_PROXY; if Node major ≥22 and NODE_OPTIONS lacks --use-env-proxy, exports NODE_OPTIONS="... --use-env-proxy" for the current session.
Persisted wrapper environment
.claude/hooks/worktree-init.sh
Adds a case stanza to the _EXPORT_BLOCK so the wrapper-persisted export includes NODE_OPTIONS with --use-env-proxy.
Shell startup persistence
/etc/profile.d/hex-bridge.sh, ~/.bashrc, ~/.zshenv (via script)
Always attempts to overwrite /etc/profile.d/hex-bridge.sh (best-effort). For ~/.bashrc and ~/.zshenv, either inserts the marker+export block when missing or backfills the --use-env-proxy case stanza when the marker exists but the stanza is absent.

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
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 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 'Fix streamlinear-cli proxy support in cloud environments' directly addresses the main change: enabling Node.js fetch() to respect HTTP_PROXY in proxy-protected cloud environments by configuring NODE_OPTIONS with --use-env-proxy.
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
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/fix-streamlinear-proxy-z5wmJ

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between 4dde00f and 9b5212d.

📒 Files selected for processing (1)
  • .claude/hooks/worktree-init.sh

Comment thread .claude/hooks/worktree-init.sh Outdated
Comment thread .claude/hooks/worktree-init.sh Outdated
- 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
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

♻️ Duplicate comments (1)
.claude/hooks/worktree-init.sh (1)

61-73: ⚠️ Potential issue | 🟠 Major

Tighten the --use-env-proxy version gate.

The comment says Node 22.21+, but the live check is only major >= 22, and the persisted _EXPORT_BLOCK drops the version guard completely. Node's enterprise proxy guide limits --use-env-proxy to v22.21.0 or v24.5.0+, while the CLI docs show NODE_USE_ENV_PROXY=1 as 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

📥 Commits

Reviewing files that changed from the base of the PR and between 9b5212d and df651e3.

📒 Files selected for processing (1)
  • .claude/hooks/worktree-init.sh

Comment thread .claude/hooks/worktree-init.sh Outdated
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
@jamesc jamesc merged commit 374a6e9 into main Mar 28, 2026
9 checks passed
@jamesc jamesc deleted the claude/fix-streamlinear-proxy-z5wmJ branch March 28, 2026 12:45
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.

3 participants