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

[Bug] HTTP Range requests send 1 byte less than requested #65

Open
jakmeier opened this issue Sep 1, 2024 · 2 comments
Open

[Bug] HTTP Range requests send 1 byte less than requested #65

jakmeier opened this issue Sep 1, 2024 · 2 comments

Comments

@jakmeier
Copy link
Contributor

jakmeier commented Sep 1, 2024

Hi!

TLDR: I found a bug and here is the fix: #64

Context:

I noticed that loading videos using a HTML5 <video> tag didn't work when I hosted my application through svelte-adapter-bun.

After a while, I figured out that all 206 partial content responses had one byte less than expected. This ended in a infinite-loop of 1-byte requests that got a 0-byte response back.

For example, this request:

GET /video/example.mp4 HTTP/1.1
Range: bytes=5742303-

I would get back

HTTP/1.1 206 Partial Content
Content-Type: video/mp4
Content-Length: 0
Content-Range: bytes 5742303-5742303/5742304
Accept-Ranges: bytes

...after which my browser just sends the same request again and again.

Eventually, I found the bug in svelte-adapter-bun, which creates a slice of a file using the inclusive end definition for a slice constructor that expects an exclusive definition. A classic off-by-one error :)

@gornostay25 Please take a look at my PR #64 to fix that.

@ckiee
Copy link
Contributor

ckiee commented Oct 22, 2024

Hi! Just wanted to say thanks, I also just hit this (:

@lc-guy
Copy link

lc-guy commented Feb 2, 2025

@gornostay25 Hello, would it be possible to create a new release for svelte-adapter-bun so that the most recent merge requests are included?

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

No branches or pull requests

3 participants