Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix(service-worker): preserve redirect policy on reconstructed asset requests - #67494

Merged
mattrbeck merged 2 commits into
angular:mainfrom
Yenya030:patch/v048-sw-request-policy-expansion
Mar 18, 2026
Merged

fix(service-worker): preserve redirect policy on reconstructed asset requests#67494
mattrbeck merged 2 commits into
angular:mainfrom
Yenya030:patch/v048-sw-request-policy-expansion

Conversation

@Yenya030

@Yenya030 Yenya030 commented Mar 6, 2026

Copy link
Copy Markdown

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?

AssetGroup.newRequestWithMetadata() reconstructs requests while preserving headers only.

In redirect handling paths (AssetGroup.fetchFromNetwork()), this drops an explicit redirect policy from the original request. As a result, a request made with redirect: 'error' can be reconstructed without that policy and continue through redirect-following behavior in the SW asset fetch path.

Issue Number: N/A

What is the new behavior?

  • Preserve redirect when reconstructing requests in newRequestWithMetadata().
  • Update service-worker test mocks to preserve request redirect semantics.
  • Add a regression test that verifies redirected lazy asset requests are rejected when redirect: 'error' is specified.

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Test plan (executed locally):

  • bazelisk test --nocache_test_results //packages/service-worker/worker/test:test --test_arg=--filter="redirect policy is error|handles redirected responses|passes headers through to the server|does not pass non-allowed metadata through to the server"
  • bazelisk test --nocache_test_results //packages/service-worker/worker/test:test
  • bazelisk test --nocache_test_results //packages/service-worker/test:test

No docs were updated because this is an internal service worker request-metadata bugfix with regression coverage in existing test suites.

@pullapprove
pullapprove Bot requested a review from kirjs March 6, 2026 16:56
@angular-robot angular-robot Bot added the area: service-worker Issues related to the @angular/service-worker package label Mar 6, 2026
@google-cla

This comment was marked as outdated.

@ngbot ngbot Bot added this to the Backlog milestone Mar 6, 2026
…requests

Preserve the redirect mode when rebuilding asset requests in newRequestWithMetadata(). This keeps explicit redirect:error semantics intact across service-worker redirect handling.

Update the worker test mocks to model redirect defaults correctly and add focused regression coverage for redirected lazy assets with redirect:error.
@Yenya030

Copy link
Copy Markdown
Author

Hello @kirjs, Have you had a chance to review my PR? Thanks!

@Yenya030

Copy link
Copy Markdown
Author

@kirjs , Its been more than a week can I get a review of my pull request?

Comment thread packages/service-worker/worker/testing/mock.ts Outdated

@JeanMeche JeanMeche left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Beside my comment, LGTM.

Use the typed Response.redirected property directly in the service-worker test mock instead of casting to any.
@Yenya030

Copy link
Copy Markdown
Author

@kirjs waiting for your review to finish this pull request.

@JeanMeche
JeanMeche removed the request for review from kirjs March 18, 2026 17:15
@JeanMeche JeanMeche added target: patch This PR is targeted for the next patch release action: merge The PR is ready for merge by the caretaker labels Mar 18, 2026
@mattrbeck
mattrbeck merged commit 57a07d0 into angular:main Mar 18, 2026
23 checks passed
@mattrbeck

Copy link
Copy Markdown
Member

This PR was merged into the repository. The changes were merged into the following branches:

@Yenya030

Copy link
Copy Markdown
Author

Great thanks for the update!

@Yenya030

Yenya030 commented Apr 7, 2026

Copy link
Copy Markdown
Author

Issue ID 493348512

@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 Apr 18, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

action: merge The PR is ready for merge by the caretaker area: service-worker Issues related to the @angular/service-worker package target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants