# Source map line numbers mismatch (Angular)

**URL:** <https://discuss.elastic.co/t/source-map-line-numbers-mismatch-angular/251795>\
**Category:** APM\
**Created:** [October 12, 2020, 4:42pm UTC](https://discuss.elastic.co/t/source-map-line-numbers-mismatch-angular/251795 "2020-10-12T16:42:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![chan-n](https://avatars.discourse-cdn.com/v4/letter/c/5e9695/32.png) [@chan-n](https://discuss.elastic.co/u/chan-n)\
**Post date:** [October 12, 2020, 4:42pm UTC](https://discuss.elastic.co/t/source-map-line-numbers-mismatch-angular/251795/1 "2020-10-12T16:42:16Z")

</div>

I am using Angular 9 and elastic/apm-rum-angular version 1.1.6.

I uploaded the source maps generated by running "ng build --source-map".

There is a mismatch between what is displayed in the "Exception stack trace" and the original TypeScript files.

APM Exception stack trace:  
 ![APM-Line70](https://us1.discourse-cdn.com/elastic/original/3X/9/1/910a16e00538ff67d4639aa3f89fccab81e7338d.png)

TypeScript file as displayed in Chrome:  
 ![Chrome-Line70](https://us1.discourse-cdn.com/elastic/original/3X/e/5/e50d2e6aa7ede602a80163e5ec66adacefa2c04d.png)

The file and line number are correct:  
"webpack:///src/app/form/form.component.ts in call at line 70"  
That correctly refers to the line with:

```auto
this.sub.unsubscribe();

```

However, in the Exception stack trace, it is missing the empty lines in between lines of code, so it's erroneously highlighting:

```auto
goToLanding() {

```

Is there a way to fix this issue/preserve the original formatting of the files when they are displayed in the Exception stack trace?

Thank you!

---

<div class="post-metadata">

**Author:** ![Emanuil](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/emanuil/32/36783_2.png) [@Emanuil](https://discuss.elastic.co/u/Emanuil)\
**Post date:** [October 15, 2020, 11:33pm UTC](https://discuss.elastic.co/t/source-map-line-numbers-mismatch-angular/251795/2 "2020-10-15T23:33:36Z")

</div>

That's not a known problem and recent fixes don't mention it.

Did you follow the [APM RUM Angular instructions](https://www.elastic.co/guide/en/apm/agent/rum-js/current/angular-integration.html)?

If so it'd be good to see your main app module where you hook RUM into your app, just to make sure that's set up right.

Which method of [source map generation & upload](https://www.elastic.co/guide/en/apm/server/7.9/sourcemaps.html#sourcemap-rum-upload) did you use? (e.g. are you using parcel, webpack, etc. - how did you generate it in case I wanted to try the same)

---

<div class="post-metadata">

**Author:** ![chan-n](https://avatars.discourse-cdn.com/v4/letter/c/5e9695/32.png) [@chan-n](https://discuss.elastic.co/u/chan-n)\
**Post date:** [October 15, 2020, 11:59pm UTC](https://discuss.elastic.co/t/source-map-line-numbers-mismatch-angular/251795/3 "2020-10-15T23:59:40Z")

</div>

Thank you for your reply, Emanuil!

Yes, I followed those Angular integration instructions.

Here are parts from my app.module.ts:

```auto
  providers: [
    ...
    {
      provide: ApmService,
      useClass: ApmService,
      deps: [Router],
    },
    {
      provide: ErrorHandler,
      useClass: ApmErrorHandler,
    },
  ],

```

(serviceName and serverUrl values have been changed to empty strings below)

```auto
export class AppModule {
  constructor(
    @Inject(ApmService) as: ApmService,
    @Inject(SettingsService) ss: SettingsService
  ) {
    ss.settings.pipe(take(1)).subscribe((settings: Record<string, string>) => {
      const env = settings.env;

      const apm = as.init({
        serviceName: '',
        serviceVersion: '1.0.0',
        serverUrl: '',
        environment: env,
      });

      apm.setUserContext({
        username: 'localhost',
        id: 'default',
      });
    });
  }
}

```

To generate the source maps, I ran ng build. "webpack" is shown in my screenshot above.  
To upload the source maps, I ran a Node.js script based on:

> **[How to apply source maps to error stack traces when using minified bundles |...](https://www.elastic.co/guide/en/apm/server/7.9/sourcemaps.html#sourcemap-custom-app)**

  
I also tried uploading them via Postman but there was no difference.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [November 5, 2020, 7:59pm UTC](https://discuss.elastic.co/t/source-map-line-numbers-mismatch-angular/251795/4 "2020-11-05T19:59:49Z")

</div>

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.
