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

Skip to content

Service Worker 504 Gateway Timeout for adsbygoogle.js resources #62055

Closed as not planned
@Zavierazo

Description

@Zavierazo

Which @angular/* package(s) are the source of the bug?

service-worker

Is this a regression?

No

Description

We're experiencing repeated TypeError: Failed to fetch errors from Angular's Service Worker (NGSW) when it attempts to fetch third-party scripts like Google Ads. These resources are not hosted by us and are loaded directly via <script> tags in index.html.

Even though the app works normally, these errors are persistent in the NGSW debug logs. When the "Service Worker network" is disabled in browser dev tools, the issue goes away — meaning the script loads correctly when not intercepted by the service worker.

Environment:

Angular Version: 19.2.14

@angular/service-worker version: 19.2.14

Site: https://vtesdecks.com/

NGSW Mode: Production

NGSW Debug Info:

Driver version: 19.2.14
Driver state: NORMAL ((nominal))
Latest manifest hash: 0df0fcb1ebeceff7f8a29f8b8efd731f45765723
Last update check: 7m14s923u

=== Version 6c239975081ad87715d3121e4b9093526d3306e9 ===

Clients: 8a3fbb51-5e48-4361-b3f9-b32e26cb663c

=== Version 0df0fcb1ebeceff7f8a29f8b8efd731f45765723 ===

Clients: 21357b7c-0590-4938-9209-d8e75620bc84, 9e67c142-e6be-481b-bcfd-5e7ceb470f28, a7290d33-640c-4980-8115-2b4ef958c320, 0cd50026-1fc8-46ac-b9cb-4dd0286fc4cb, 6bd59e86-2848-4449-acb3-6ccfa8bb6547, 91300d67-818d-46c7-acc1-94d51dc5eabb, b666de4d-998c-4ddd-bacf-40da52d8d28e, 71144ee5-2cce-4182-9043-e587d40bbcf7, a081d0f4-cd0b-49a8-b2d8-576382abc6c5, ad654891-6b0a-457f-bb3c-666a367328e6, 3ff71702-74a4-40d0-9bf4-794886d38602, bb64c51a-720f-4f2f-94ff-2a2b738ee643, 98ec2507-50e3-42a3-b106-39928af15575, 100d17c5-1dac-435c-8f24-cedfdf62a697, 64f5b4de-d3a8-43d2-bfb2-92ee62248657, 0db09ad3-663c-43be-8911-320457ab5ead, 563c85cc-1fea-43a0-a347-02479eaee68a, 923cb0a9-0165-476c-82f3-7e7c0cc2a6ef

=== Idle Task Queue ===
Last update tick: 88u
Last update run: 7m14s961u
Task queue:
 * check-updates-on-navigation

Debug log:

[10m17s305u] TypeError(Failed to fetch, TypeError: Failed to fetch
    at Driver.safeFetch (https://vtesdecks.com/ngsw-worker.js:1892:33)
    at Driver.handleFetch (https://vtesdecks.com/ngsw-worker.js:1510:23)) Driver.fetch(https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-7379021241824282&v=2.43.0)

Script load: https://github.com/Zavierazo/vtesdecks-front/blob/main/src/app/app.component.ts#L170-L180

ngsw-config.json: https://github.com/Zavierazo/vtesdecks-front/blob/main/ngsw-config.json

Questions:

Is it expected behavior for NGSW to intercept or attempt to fetch external scripts like these?

Is there a way to explicitly exclude URLs (especially cross-origin) from being handled by the service worker?

Any guidance on best practices here would be greatly appreciated.

Thanks for your support!

Please provide a link to a minimal reproduction of the bug

https://vtesdecks.com/

Please provide the exception or error you saw

[10m17s305u] TypeError(Failed to fetch, TypeError: Failed to fetch
    at Driver.safeFetch (https://vtesdecks.com/ngsw-worker.js:1892:33)
    at Driver.handleFetch (https://vtesdecks.com/ngsw-worker.js:1510:23)) Driver.fetch(https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-7379021241824282&v=2.43.0)

Please provide the environment you discovered this bug in (run ng version)

Angular CLI: 19.2.15
Node: 22.16.0
Package Manager: npm 10.8.3
OS: win32 x64

Angular: 19.2.14
... animations, common, compiler, compiler-cli, core, elements
... forms, localize, platform-browser, platform-browser-dynamic
... router, service-worker

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1902.15
@angular-devkit/build-angular   19.2.15
@angular-devkit/core            19.2.15
@angular-devkit/schematics      19.2.15
@angular/cdk                    19.2.18
@angular/cli                    19.2.15
@angular/pwa                    19.2.15
@schematics/angular             19.2.15
rxjs                            7.8.2
typescript                      5.8.3
zone.js                         0.15.1

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions