Skip to content

fix(service-worker): update service worker to handle seeking better for videos . - #60007

Closed
Beanminchild wants to merge 2 commits into
angular:mainfrom
Beanminchild:main
Closed

Beanminchild wants to merge 2 commits into
angular:mainfrom
Beanminchild:main

Conversation

@Beanminchild

@Beanminchild Beanminchild commented Feb 19, 2025 •

Copy link
Copy Markdown
Contributor

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • angular.dev application / infrastructure changes
  • Other... Please describe:

What is the current behavior?

Issue Number: #25865

What is the new behavior?

1.) Fetch Event Listener: The service worker listens for fetch events and checks if the request contains a range header.

2.) Range Request Handling: If a range header is present, the service worker calls the handleRangeRequest function to process the request.

3.) Partial Content Response: The handleRangeRequest function extracts the requested byte range from the range header, retrieves the requested resource from the cache, slices the resource to the specified byte range, and returns a 206 Partial Content response with the appropriate Content-Range header.

This ensures that video seeking works correctly when videos are delivered by the service worker.

Does this PR introduce a breaking change?

  • Yes
  • No : Has error handling and falls back to normal request if content is not a video

I saw this problem was a bit of a necro thread thats been an issue for quite some time. There was a workaround in the chat that did something similar to what im doing here but i figured it would be nice if this logic was just built in instead of people needing to implement a third party hack. Based on my local testing this should work as expected but please feel free to give me any feedback, concerns or needed improvements and ill be happy to implement them to get this bug fix finally squared away :)

@google-cla

google-cla Bot commented Feb 19, 2025

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@JeanMeche
JeanMeche marked this pull request as ready for review February 19, 2025 14:40
@JeanMeche
JeanMeche marked this pull request as draft February 19, 2025 14:40
@pullapprove
pullapprove Bot requested a review from atscott February 19, 2025 14:40
@Beanminchild
Beanminchild marked this pull request as ready for review February 19, 2025 16:16
@kirjs kirjs added the area: service-worker Issues related to the @angular/service-worker package label Feb 19, 2025
@ngbot ngbot Bot added this to the Backlog milestone Feb 19, 2025
@Beanminchild Beanminchild changed the title #25865 Service worker doesn't support seeking in videos fix(service-worker): update service worker to handle seeking better for videos . Feb 19, 2025
…or videos

This update ensures that the service worker can handle range requests, allowing video seeking to work correctly when videos are delivered by the service worker.
@Beanminchild

Copy link
Copy Markdown
Contributor Author

Apologies, Linting failed because i didn't follow naming conventions for commit message

@atscott

atscott commented Feb 19, 2025

Copy link
Copy Markdown
Contributor

I don't think this is what's required for #25865. The change made here is updating example code that is just meant to "mock" out the service worker without functionality. I'm going to close this since the change doesn't seem right to me.

@atscott atscott closed this Feb 19, 2025
@Beanminchild

Beanminchild commented Feb 19, 2025 •

Copy link
Copy Markdown
Contributor Author

ah okay i was following a suggestion in the comments. i can dig deeper into the project structure and try a more correct solution... ill make sure to do more verification before i open any other prs so i dont spam. Thanks for the feedback

@angular-automatic-lock-bot

Copy link
Copy Markdown

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot Bot locked and limited conversation to collaborators Mar 22, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area: service-worker Issues related to the @angular/service-worker package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants