[PR #30] [MERGED] Fix binary response handling in Pages Router prod server #253

Closed
opened 2026-05-06 12:38:47 +02:00 by BreizhHardware · 0 comments

📋 Pull Request Information

Original PR: https://github.com/cloudflare/vinext/pull/30
Author: @linares222
Created: 2/24/2026
Status: Merged
Merged: 2/25/2026
Merged by: @southpolesteve

Base: mainHead: fix-binary-response-handling


📝 Commits (1)

  • 9e133ba fix: preserve binary API response bytes in prod-server

📊 Changes

3 files changed (+22 additions, -2 deletions)

View changed files

📝 packages/vinext/src/server/prod-server.ts (+2 -2)
tests/fixtures/pages-basic/pages/api/binary.ts (+9 -0)
📝 tests/pages-router.test.ts (+11 -0)

📄 Description

Fixes a Pages Router prod-server response handling bug where response.text() could corrupt binary payloads.

Changes

  • Switch Pages Router prod response reads from response.text() to Buffer.from(await response.arrayBuffer())
  • Add /api/binary fixture route returning known bytes
  • Add regression test asserting exact byte preservation for /api/binary

Why

API routes can return raw bytes (res.end(Buffer)). Decoding as text before writing can mangle non-UTF8 bytes.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/cloudflare/vinext/pull/30 **Author:** [@linares222](https://github.com/linares222) **Created:** 2/24/2026 **Status:** ✅ Merged **Merged:** 2/25/2026 **Merged by:** [@southpolesteve](https://github.com/southpolesteve) **Base:** `main` ← **Head:** `fix-binary-response-handling` --- ### 📝 Commits (1) - [`9e133ba`](https://github.com/cloudflare/vinext/commit/9e133ba4485190110d42cff2f1c985e7161c05d3) fix: preserve binary API response bytes in prod-server ### 📊 Changes **3 files changed** (+22 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `packages/vinext/src/server/prod-server.ts` (+2 -2) ➕ `tests/fixtures/pages-basic/pages/api/binary.ts` (+9 -0) 📝 `tests/pages-router.test.ts` (+11 -0) </details> ### 📄 Description Fixes a Pages Router prod-server response handling bug where `response.text()` could corrupt binary payloads. ### Changes - Switch Pages Router prod response reads from `response.text()` to `Buffer.from(await response.arrayBuffer())` - Add `/api/binary` fixture route returning known bytes - Add regression test asserting exact byte preservation for `/api/binary` ### Why API routes can return raw bytes (`res.end(Buffer)`). Decoding as text before writing can mangle non-UTF8 bytes. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
BreizhHardware 2026-05-06 12:38:47 +02:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/vinext#253
No description provided.