Skip to content

Commit 2862313

Browse files
feat(angular): Add service worker guide for fixing invalid file hashes in ngsw (#11494)
--------- Co-authored-by: Lukas Stracke <[email protected]>
1 parent 3e148d0 commit 2862313

File tree

3 files changed

+34
-3
lines changed

3 files changed

+34
-3
lines changed

docs/platforms/javascript/common/sourcemaps/uploading/cli.mdx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,21 @@ If you want to configure source map uploading using the CLI, follow the steps be
3030
You can generate source maps using the tooling of your choice. See examples from other guides linked under <PlatformLink to="/sourcemaps/uploading/">Uploading Source Maps</PlatformLink>.
3131

3232
<Include name="sentry-cli-sourcemaps.mdx" />
33+
34+
<PlatformSection supported={['javascript.angular']}>
35+
36+
## Fixing Angular Service Worker caching issues
37+
38+
If you use the [Angular service worker](https://angular.dev/ecosystem/service-workers), you might encounter caching issues when uploading source maps with Sentry CLI.
39+
This happens because Sentry CLI injects debugIds into the generated JavaScript chunks after the build process.
40+
This means that the file hashes in `ngsw.json` for these chunks become invalid.
41+
To resolve the invalid hashes, regenerate `ngsw.json` after the debugIds have been injected using the following command:
42+
43+
```bash
44+
node_modules/.bin/ngsw-config <dist> <config>
45+
```
46+
47+
- `dist` Path to the built chunk files. The `ngsw.json` with the old hashes should be located there.
48+
- `config` Location of `ngsw-config.json` (should be in project root)
49+
50+
</PlatformSection>

docs/platforms/javascript/common/troubleshooting/index.mdx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,4 +386,17 @@ export default defineConfig({
386386
387387
</Expandable>
388388
389+
<PlatformSection supported={['javascript.angular']}>
390+
391+
<Expandable
392+
permalink
393+
title="Invalid hashes in Angular Service Worker ngsw.json"
394+
>
395+
If you upload source maps for your Angular application with <PlatformLink to="/sourcemaps/uploading/cli">Sentry CLI</PlatformLink>, you might encounter caching issues if you use the [Angular service worker](https://angular.dev/ecosystem/service-workers).
396+
Learn more about fixing these caching issues in the <PlatformLink to="/sourcemaps/uploading/cli/#fixing-angular-service-worker-caching-issues">Uploading Source Maps with Sentry CLI</PlatformLink> guide.
397+
398+
</Expandable>
399+
400+
</PlatformSection>
401+
389402
If you need additional help, you can [ask on GitHub](https://github.com/getsentry/sentry-javascript/issues/new/choose). Customers on a paid plan may also contact support.

platform-includes/sourcemaps/upload/primer/javascript.angular.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
To upload your Angular project's source maps to Sentry, we recommend one of these options:
22

3-
- [**Angular CLI and Sentry webpack plugin**](./angular-webpack/) <br/>
3+
- [Angular CLI and Sentry webpack plugin](./angular-webpack/) <br/>
44
Use the Angular CLI, a custom Angular builder and the Sentry webpack plugin to set releases and upload source maps automatically when running `ng build`.
5-
- [**Nx Angular CLI and Sentry webpack plugin**](./angular-nx/) <br/>
5+
- [Nx Angular CLI and Sentry webpack plugin](./angular-nx/) <br/>
66
If you're using Nx, use `@nx/angular` CLI and the Sentry webpack plugin to set releases and upload source maps automatically when running `nx build`.
7-
- [**Sentry CLI**](./cli/)<br/>
7+
- [Sentry CLI](./cli/)<br/>
88
Upload source maps manually using Sentry CLI.
99

1010
These options work well with Angular projects out of the box. For other bundlers or more advanced projects and configurations, take a look at the following guides and options for uploading sourcemaps:

0 commit comments

Comments
 (0)