Skip to content

fix(proxy): skip empty passthrough body streams - #854

Merged
harlan-zw merged 1 commit into
mainfrom
fix/empty-proxy-body
Aug 6, 2026
Merged

fix(proxy): skip empty passthrough body streams#854
harlan-zw merged 1 commit into
mainfrom
fix/empty-proxy-body

Conversation

@harlan-zw

Copy link
Copy Markdown
Collaborator

🔗 Linked issue

Resolves #853

❓ Type of change

  • 📖 Documentation
  • 🐞 Bug fix
  • 👌 Enhancement
  • ✨ New feature
  • 🧹 Chore
  • ⚠️ Breaking change

📚 Description

Empty beacon POSTs with Content-Length: 0 were forwarded with a ReadableStream body, causing Node fetch to reject and the proxy to return 502. The proxy now omits the body and duplex option for explicitly empty requests while preserving streams for nonempty opaque bodies.

@vercel

vercel Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
scripts-playground Ready Ready Preview Aug 6, 2026 2:22pm

Request Review

@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: e15e5c96-9594-4126-bdd4-e9b508a8a24d

📥 Commits

Reviewing files that changed from the base of the PR and between 2db3380 and 427d4bd.

📒 Files selected for processing (2)
  • packages/script/src/runtime/server/proxy-handler.ts
  • test/unit/proxy-handler-body.test.ts

📝 Walkthrough

Walkthrough

The proxy now omits the upstream body stream when the original request has content-length: 0. It sets duplex: 'half' only when the forwarded body is a ReadableStream. Unit tests capture upstream body and duplex values, verify gzip streaming, and cover empty opaque POST requests.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main fix: skipping empty passthrough body streams.
Description check ✅ Passed The description directly explains the empty beacon POST bug and the proxy fix.
Linked Issues check ✅ Passed The changes prevent empty request streams, conditionally set duplex, and preserve nonempty streaming as required by issue #853.
Out of Scope Changes check ✅ Passed The changes are limited to proxy body handling and tests for the linked issue.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ 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 fix/empty-proxy-body

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.

@pkg-pr-new

pkg-pr-new Bot commented Aug 6, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@nuxt/scripts@854

commit: 427d4bd

@harlan-zw
harlan-zw merged commit 2331d7a into main Aug 6, 2026
15 checks passed
@harlan-zw
harlan-zw deleted the fix/empty-proxy-body branch August 6, 2026 15:10
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.

Empty sendBeacon POST fails in first-party proxy with 502

1 participant