Skip to content

Fix hangin seek requests#5

Open
lejeunerenard wants to merge 8 commits into
mainfrom
fix-hangin-seek-requests
Open

Fix hangin seek requests#5
lejeunerenard wants to merge 8 commits into
mainfrom
fix-hangin-seek-requests

Conversation

@lejeunerenard

Copy link
Copy Markdown
Contributor

This fix prevents throwing an uncaught REQUEST_CANCELLED when destroying a stream that can't fulfill the seek requests for setting up the stream.

Also fixes bug where a combination of custom start & length options could request more blocks than necessary for prefetch.

Co-written with AI

The seek requests in the _open'ing of the stream will correctly be
cancelled as part of destroying the core. This means they will be
uncaught, a change from the start seek in `v2.0.2`.
Without this, the stream could include incorrect `start` & `length`
options that cause the `bytes` to seek to for the end to be far past the
`id` & even the end of the core.

The fix was to cap the end to the max bytes taking the similar approach
to how web servers respond to invalid byte ranges in HTTP request.
source: https://www.rfc-editor.org/info/rfc9110/#byte.ranges
Recreating behavior for `start` seek in `v2.0.2`.
The test can kill the whole script instead.
@lejeunerenard lejeunerenard requested a review from a team June 12, 2026 22:39
Comment thread index.js
}

const [start, end] = await Promise.all([this._setStart(), this._prefetch ? this._setEnd() : Promise.resolve(0)])
let start, end

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Make two lets, init to 0 also

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.

2 participants