Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: range end is zero-indexed #3826

Merged
merged 2 commits into from
Nov 12, 2024
Merged

Conversation

DTrombett
Copy link
Contributor

@DTrombett DTrombett commented Nov 12, 2024

This relates to...

The retry interceptor treats the end parameter of the Range or Content-Range header as 1-indexed (or 0-indexed but exclusive), leading to an error, for example, when the Content-Range header is not present and end is assigned to the value of the Content-Length header:

AssertionError [ERR_ASSERTION]: content-range mismatch
    at RetryHandler.onHeaders (D:\_\node_modules\undici\lib\handler\retry-handler.js:236:7)
    at downstreamOnHeaders (D:\_\node_modules\undici\lib\handler\cache-handler.js:64:53)
    at CacheHandler.onHeaders (D:\_\node_modules\undici\lib\handler\cache-handler.js:112:14)
    at CookieHandler.onHeaders (D:\_\node_modules\http-cookie-agent\dist\undici\cookie_handler.js:43:28)
    at Request.onHeaders (D:\_\node_modules\undici\lib\core\request.js:246:29)
    at Parser.onHeadersComplete (D:\_\node_modules\undici\lib\dispatcher\client-h1.js:612:27)
    at wasm_on_headers_complete (D:\_\node_modules\undici\lib\dispatcher\client-h1.js:141:30)
    at wasm://wasm/00032d9a:wasm-function[10]:0x56f
    at wasm://wasm/00032d9a:wasm-function[20]:0x7d57
    at Parser.execute (D:\_\node_modules\undici\lib\dispatcher\client-h1.js:332:22) {
  generatedMessage: false,
  code: 'ERR_ASSERTION',
  actual: false,
  expected: true,
  operator: '=='
}

Rationale

This PR fixes the issue above by subtracting 1 to Content-Length or the size parameter of the Content-Range header

Changes

Features

Bug Fixes

Breaking Changes and Deprecations

Status

@DTrombett DTrombett changed the title Fix/retry range fix: range end is zero-indexed Nov 12, 2024
Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

lgtm

@mcollina mcollina merged commit 2b81fbc into nodejs:main Nov 12, 2024
38 checks passed
github-actions bot pushed a commit that referenced this pull request Nov 12, 2024
* fix: range end is zero-indexed

* tests: update tests for retry handler

(cherry picked from commit 2b81fbc)
Uzlopak pushed a commit that referenced this pull request Nov 12, 2024
* fix: range end is zero-indexed

* tests: update tests for retry handler

(cherry picked from commit 2b81fbc)

Co-authored-by: D Trombett <[email protected]>
@DTrombett DTrombett deleted the fix/retry-range branch November 12, 2024 22:54
flakey5 pushed a commit to flakey5/undici that referenced this pull request Nov 14, 2024
* fix: range end is zero-indexed

* tests: update tests for retry handler
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants