mirror of
https://github.com/cloudflare/vinext.git
synced 2026-05-09 08:25:34 +02:00
[PR #176] [MERGED] fix: bound fetch cache key body serialization #371
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#371
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/176
Author: @dknecht
Created: 2/27/2026
Status: ✅ Merged
Merged: 2/27/2026
Merged by: @threepointone
Base:
main← Head:codex/fix-unbounded-memory-usage-in-cached-fetch📝 Commits (2)
6e68559fix: bound fetch cache key body serializationbff0861Safeguard cache key serialization from large bodies📊 Changes
2 files changed (+241 additions, -57 deletions)
View changed files
📝
packages/vinext/src/shims/fetch-cache.ts(+78 -53)📝
tests/fetch-cache.test.ts(+163 -4)📄 Description
Motivation
BodyInittypes (streams, blobs, form data) with no size limit, allowing an attacker to cause unbounded memory growth during cachedfetch()calls.Description
MAX_CACHE_KEY_BODY_BYTES(1 MiB) and aBodyTooLargeForCacheKeyErrorto guard cache-key body serialization and abort unsafe buffering.ReadableStream.prototype.tee()so one branch is consumed for cache-key hashing while the other branch is forwarded to the real fetch without reconstructing a full in-memory buffer.Uint8Array, streamed chunks,FormDatafiles), short-circuit cache-key generation and fall back to passing the request through tooriginalFetch(i.e., bypass caching) to avoid buffering;_ogBodyrestoration remains supported for safe cases.BlobandReadableStreambodies bypass the cache and still perform the network fetch.Testing
pnpm test tests/fetch-cache.test.ts, which passed (54 testsall green).pnpm run typecheck, which completed successfully with no type errors.Codex Task
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.