Skip to content

fix: use agents: false for ws upgrade#129

Merged
pi0 merged 1 commit intounjs:mainfrom
danielroe:fix/ws-keepalive
Apr 21, 2026
Merged

fix: use agents: false for ws upgrade#129
pi0 merged 1 commit intounjs:mainfrom
danielroe:fix/ws-keepalive

Conversation

@danielroe
Copy link
Copy Markdown
Member

@danielroe danielroe commented Apr 21, 2026

websocket upgrade connections shouldn't have keep-alive set....

this causes isssues with deno - spotted in nuxt/cli#1284

Summary by CodeRabbit

Bug Fixes

  • WebSocket upgrade requests now properly disable keep-alive agent handling, ensuring consistent behavior with HTTP/2 connection management.

Tests

  • Added test coverage for WebSocket upgrade request handling to validate agent configuration.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 21, 2026

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

Modified setupOutgoing to disable the keep-alive agent for WebSocket upgrade requests (in addition to existing HTTP/2 handling) by checking the Connection header for an Upgrade token, with corresponding test coverage added.

Changes

Cohort / File(s) Summary
Agent Suppression Logic
src/_utils.ts
Expanded condition to disable outgoing.agent when incoming request contains WebSocket Upgrade token in Connection header, alongside existing HTTP/2 suppression logic.
WebSocket Upgrade Test
test/_utils.test.ts
Added test case validating that outgoing.agent is set to false for WebSocket upgrade requests with headers.connection: "Upgrade" and headers.upgrade: "websocket".

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • pi0
  • sapphi-red

Poem

🐰 A rabbit hops through protocol streams,
Where sockets upgrade to WebSocket dreams,
No agents linger when upgrades take flight,
HTTP/2 and WebSockets both handled just right! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and concisely describes the main change: disabling agents for WebSocket upgrade requests, which matches the core modification in the changeset.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ 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.

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 21, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.91%. Comparing base (5e96343) to head (8d00e0d).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #129   +/-   ##
=======================================
  Coverage   94.91%   94.91%           
=======================================
  Files           8        8           
  Lines         786      786           
  Branches      320      320           
=======================================
  Hits          746      746           
  Misses         35       35           
  Partials        5        5           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@pi0 pi0 merged commit 558ed9e into unjs:main Apr 21, 2026
4 of 5 checks passed
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