Skip to content

fix: prevent double-skip in revalidate path by clearing fillRange context#59

Merged
sendya merged 2 commits into
mainfrom
fix/issue-58-double-skip-revalidate
Jun 1, 2026
Merged

fix: prevent double-skip in revalidate path by clearing fillRange context#59
sendya merged 2 commits into
mainfrom
fix/issue-58-double-skip-revalidate

Conversation

@sendya
Copy link
Copy Markdown
Member

@sendya sendya commented Jun 1, 2026

Summary

  • 修复 revalidate 路径中 lazilyRespondfillRange.PostRequest 对响应 body 双重 skip 导致 unexpected EOF 的问题
  • revalidate() 调用 lazilyRespond 前清除 request context 中的 fillRangeKey,防止 fillRange.PostRequest 重复应用 RangeReader

Root Cause

lazilyRespond 从缓存块构建 206 响应时已通过 SkipReadCloser 将 body 定位到正确的起始偏移量,但 fillRange.PostRequest 在 post process chain 中再次用 RangeReader 裁剪同一偏移量,造成数据错位。

Test plan

  • 编译通过
  • 全部已有测试通过
  • 验证 revalidate + range 请求场景无双重 skip

Closes #58

🤖 Generated with Claude Code

…text before lazyRespond

When revalidating a range request, lazilyRespond already applies correct
range trimming via SkipReadCloser. The subsequent fillRange.PostRequest
wrapped the body again with RangeReader, causing a double skip that
resulted in unexpected EOF.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings June 1, 2026 02:05
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a double range-trim bug in the revalidate path. When a 304 revalidation produces a 206 from cache via lazilyRespond, lazilyRespond already trims the body to the requested offset using SkipReadCloser/LimitReadCloser. The downstream fillRange.PostRequest would then wrap the same body again with RangeReader, skipping additional bytes and causing data misalignment / "unexpected EOF". The fix clears the fillRangeKey value in the request context before calling lazilyRespond, so fillRange.PostRequest's frk != nil guard short-circuits.

Changes:

  • In RevalidateProcessor.revalidate, before serving a range-aware 304 hit via lazilyRespond, mutate the request's context to remove the fillRangeKey value, so fillRange.PostRequest skips its RangeReader wrapping.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@sendya sendya merged commit d70656f into main Jun 1, 2026
1 check passed
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.

unexpected eof and double skip

2 participants