Repository navigation
fix(next): stop the image optimizer hanging after a cancelled request / 修复请求取消后图片优化器卡住的问题 - #1545
Merged
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This was referenced Oct 28, 2026
Patch [email protected] through root patchedDependencies. Unpatched, the self-hosted optimizer reads a local source image through a mocked request that reuses the browser socket. When the browser cancels the image, the read is dropped and every later request for that variant hangs until the server restarts. A unit test fails if a Next upgrade loses the patch, and the unit and E2E workflows now run when patches/ changes. 中文:通过根目录 patchedDependencies 为 [email protected] 打补丁。未打补丁时, 自托管图片优化器复用浏览器 socket 读取本地源图,浏览器取消请求后读取被丢弃, 同一尺寸的后续请求会一直挂起,直到服务重启。新增单元测试在升级 Next 丢失补丁 时失败,patches/ 变更也会触发单元测试与 E2E 工作流。
adibarra
force-pushed
the
fix/next-image-optimizer-hang
branch
from
October 29, 2026 02:06
153ffcf to
d78bbd5
Compare
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Part 1 of the stack split from #1530. Review and merge in order. CI only runs on PRs that target
master, so each layer was verified locally; the combined change passed full CI on #1530.Stack (merge in order):
Next 16.3.3's self-hosted image optimizer reads local source images through a mocked request that reuses the browser socket. If the browser cancels that request within a few milliseconds, the file read is dropped. The mock never finishes, and every later request for the same image variant waits on it until the server restarts.
This PR patches
fetchInternalImagethrough rootpatchedDependencies(patches/[email protected]).next-image-optimizer-patch.test.tsfails if a Next upgrade drops the patch, andpatches/**is added to the unit and E2E workflow path filters.Later PRs in this stack route blog figures through
next/image, which made Firefox E2E hit this bug. Production on Vercel uses Vercel's image service and should be unaffected, though that is not verified.Validation details
Full CI runs on this PR (it targets
master). Lint, format, typecheck and the full unit suite pass on this layer.AI model disclosure
anthropic/claude-opus-5-5(runtime-exposed identifier for the coordinating agent).PR checklist
inferencex-skillschanges (no filters or views change)/zhsiblingdocs/chinese-copy.md(Chinese maintainer review pending)中文
本 PR 为从 #1530 拆分的 stack 中的第 1 部分,请按顺序审核与合并。CI 只在以
master为目标的 PR 上运行,因此每一层都在本地验证;整体改动已在 #1530 上通过完整 CI。Next 16.3.3 的自托管图片优化器通过复用浏览器 socket 的模拟请求读取本地源图片。浏览器若在数毫秒内取消请求,文件读取会被丢弃,模拟请求永远不会完成,之后对同一图片变体的请求都会等待它,直到服务器重启。
本 PR 通过根目录
patchedDependencies(patches/[email protected])修补fetchInternalImage。若 Next 升级后补丁丢失,next-image-optimizer-patch.test.ts会失败;patches/**已加入单元测试与 E2E workflow 的路径过滤。本 stack 后续 PR 让博客配图经过
next/image,Firefox E2E 因此触发了该缺陷。Vercel 生产环境使用其自身的图片服务,预计不受影响(尚未验证)。验证:本 PR 以
master为目标,会运行完整 CI。本层的 lint、格式、类型检查与完整单元测试均通过。AI 模型使用说明:协调 agent 使用
anthropic/claude-opus-5-5(运行环境提供的标识),负责审计、规划与整合改动、拆分 stack 以及撰写提交与 PR 文本;委派的子 agent 在同一环境中实现各部分、构建 stack 并运行验证,其确切模型标识无法获取,因此无法确认。Note
Medium Risk
It changes Next’s server-side image optimization path used by self-hosted
next startand CI; the regression test mitigates accidental patch loss on upgrades, but Vercel’s hosted optimizer is a separate code path.Overview
Adds a Bun
patchedDependenciespatch for[email protected]sofetchInternalImageno longer passes the browser’s socket into the mocked internal read. When a client cancels early, the old behavior could abort the source stream, leave one optimization stuck in the shared cache, and block later requests for the same variant (including pageload) until restart.patches/[email protected]applies that change in Next’s compiledimage-optimizerbundles;package.json/bun.lockwire it up. A new Vitest innext-image-optimizer-patch.test.tssimulates a destroyed socket and asserts the optimizer still returns the image, so a Next upgrade that drops the patch fails CI. Unit and E2E workflows now watchpatches/**, anddocs/deployment-configuration.mddocuments the self-hosted /next startrationale and how to refresh the patch after upgrades.Reviewed by Cursor Bugbot for commit d78bbd5. Bugbot is set up for automated code reviews on this repo. Configure here.