mirror of
https://github.com/cloudflare/vinext.git
synced 2026-05-09 08:25:34 +02:00
[PR #513] [MERGED] fix: image optimizer fallback stream reuse #635
Labels
No labels
enhancement
enhancement
good first issue
help wanted
nextjs-tracking
nextjs-tracking
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/vinext#635
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/cloudflare/vinext/pull/513
Author: @JaredStowell
Created: 3/13/2026
Status: ✅ Merged
Merged: 3/13/2026
Merged by: @james-elicx
Base:
main← Head:jstowell/fix-image-optimizer-fallback📝 Commits (2)
855211dfix image optimizer fallback906b47arefetch on failure📊 Changes
4 files changed (+291 additions, -15 deletions)
View changed files
📝
packages/vinext/src/index.ts(+2 -1)📝
packages/vinext/src/server/image-optimization.ts(+25 -11)➕
tests/image-optimization-parity.test.ts(+151 -0)📝
tests/shims.test.ts(+113 -3)📄 Description
Fix
/_vinext/imagefallback behavior when image transformation fails after consuming the source stream.This also fixes a Pages Router dev-mode parity bug where local image redirects did not percent-encode unicode paths in the
Locationheader.Root cause
The image optimization path on Workers streams the source image into the transform handler. If the transform implementation starts consuming the source stream and then throws, the original response body can no longer be reused safely for fallback.
Fix
This keeps the normal success path streaming and avoids tee-based buffering, while still recovering correctly from consumed-stream failures.
Changes
Locationheaders for unicode pathsTesting
pnpm test tests/shims.test.ts -t "handleImageOptimization"pnpm test tests/image-optimization-parity.test.tspnpm run fmtpnpm run typecheck🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.