# Sourcemaps are not getting applied

**URL:** <https://discuss.elastic.co/t/sourcemaps-are-not-getting-applied/244679>\
**Category:** APM\
**Tags:** rum\
**Created:** [August 12, 2020, 8:38am UTC](https://discuss.elastic.co/t/sourcemaps-are-not-getting-applied/244679 "2020-08-12T08:38:51Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hamunaptroid](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hamunaptroid/32/63795_2.png) [@Hamunaptroid](https://discuss.elastic.co/u/Hamunaptroid)\
**Post date:** [August 12, 2020, 8:38am UTC](https://discuss.elastic.co/t/sourcemaps-are-not-getting-applied/244679/1 "2020-08-12T08:38:51Z")

</div>

Hello, I have been having problems with RUM agent. Stack traces are not shown. In Kibana there is just "stack trace is not available".

In APM server I can see this error:

**2020-08-11T09:35:34.035+0200 WARN [stacktrace] model/stacktrace.go:62 Cannot apply sourcemap without a service name or service version**

but it gets accepted ...

**2020-08-11T11:04:36.599+0200 INFO [request] middleware/log\_middleware.go:97 request accepted {"request\_id": "52d735b4-45a2-4252-b7b8-a5e3a5308184", "method": "POST", "URL": "/intake/v2/rum/events", "content\_length": 19119, "remote\_address": "** [**10.10.22.14**](https://10.10.22.14) **", "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)", "response\_code": 202}**

This is what apm-server.yml looks like:

rum:

enabled: true

apm-server.rum.enabled: true

apm-server.rum.source\_mapping.enabled: true

apm-server.rum.allow\_origins: ['\*']

apm-server.rum.source\_mapping.index\_pattern: "apm-\*"

And this is .js that we use to configure sourcemaps:

window.REACT\_APP\_AMP\_CONFIG\_ENABLED = true;

window.REACT\_APP\_AMP\_CONFIG = {

// Set required service name (allowed characters: a-z, A-Z, 0-9, -, \_, and space)

serviceName: 'FrontEnd',

// Set custom APM Server URL (default: [http://localhost:8200](http://localhost:8200))

serverUrl: '[https://FrontEnd.pls.lab:8443/apm/](https://dmvs.mvs.lab:8443/apm/)',

// Set service version (required for sourcemap feature)

serviceVersion: '',

//logLevel: 'debug'

I have played with apm-config a little, I have tried to put something into serviceVersion: ... but nothing happens, chunk.js files didn't have full path in "//# sourceMappingURL=" so I added full path to the sourceMaps ... its still the same and still same error that It cant apply sourcemaps, so in Kibana its just "no stack trace available"

I am lost ... Nothing I tried helps. I would be grateful for any suggestions.

Thank you.

Whole elastic stack is on 7.8

---

<div class="post-metadata">

**Author:** ![jalvz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jalvz/32/45613_2.png) [@jalvz](https://discuss.elastic.co/u/jalvz)\
**Post date:** [August 12, 2020, 10:02am UTC](https://discuss.elastic.co/t/sourcemaps-are-not-getting-applied/244679/2 "2020-08-12T10:02:43Z")

</div>

Hello,

Just to make sure because you don't explicitly mention it: Sourcemaps need to be uploaded to APM Server first. Did you follow instructions in [https://www.elastic.co/guide/en/apm/server/current/sourcemap-api.html](https://www.elastic.co/guide/en/apm/server/current/sourcemap-api.html)?

If so, what result are you seeing from executing the request?  
You can also search the `apm-sourcemap` index in Elasticserch: do you get any hits?

---

<div class="post-metadata">

**Author:** ![Hamunaptroid](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hamunaptroid/32/63795_2.png) [@Hamunaptroid](https://discuss.elastic.co/u/Hamunaptroid)\
**Post date:** [August 13, 2020, 9:10am UTC](https://discuss.elastic.co/t/sourcemaps-are-not-getting-applied/244679/3 "2020-08-13T09:10:40Z")

</div>

Hello,

Thank you for reply,

Sourcemaps should be getting uploaded via custom app.  
I have searched apm-sourcemap index and this is what I see:

```
GET apm-*/_search
{
  "query": {
    "term": {
      "processor.event": "sourcemap"
    }
  }
}

{
  "took" : 7,
  "timed_out" : false,
  "_shards" : {
    "total" : 172,
    "successful" : 172,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 0,
      "relation" : "eq"
    },
    "max_score" : null,
    "hits" : []
  }
}

```

so does it mean sourcemaps are not really in our apm-server ?  
Can be serviceVersion empty ? serviceName is set.

Thank you.

---

<div class="post-metadata">

**Author:** ![jalvz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jalvz/32/45613_2.png) [@jalvz](https://discuss.elastic.co/u/jalvz)\
**Post date:** [August 13, 2020, 10:48am UTC](https://discuss.elastic.co/t/sourcemaps-are-not-getting-applied/244679/4 "2020-08-13T10:48:58Z")

</div>

Hello!

You found it, `serviceVersion` can't be empty, so your upload request is failing (presumably silently).  
You need to upload your sourcemaps with a `serviceVersion` matching the one you use for configuring the agent, see: [https://www.elastic.co/guide/en/apm/agent/rum-js/current/sourcemap.html](https://www.elastic.co/guide/en/apm/agent/rum-js/current/sourcemap.html) and [https://www.elastic.co/guide/en/apm/agent/rum-js/current/configuration.html#service-version](https://www.elastic.co/guide/en/apm/agent/rum-js/current/configuration.html#service-version).

Normally setting the version is optional, but when using sourcemaps it is important to version the software so we can know which sourcemap to use for each release.

So pass in a version (it can be Semver, a Git hash, whatever), use the same one when initializing the agent, and run that query against Elasticsearch again to confirm it was uploaded.

Hope this helps!

---

<div class="post-metadata">

**Author:** ![Hamunaptroid](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hamunaptroid/32/63795_2.png) [@Hamunaptroid](https://discuss.elastic.co/u/Hamunaptroid)\
**Post date:** [August 13, 2020, 3:09pm UTC](https://discuss.elastic.co/t/sourcemaps-are-not-getting-applied/244679/5 "2020-08-13T15:09:15Z")

</div>

Hello,

Interesting ... When I check Kibana for some errors and I open it's metadata, I can see all that is needed but I still see the error message in apm logs and without stack trace.

```
###### Service

| **service.language.name** |javascript|
| --- | --- |
| **service.name** |FrontEnd|
| **service.version** |1.2.3|

```

This is just info about the agent configuration ?

Sometimes I get confused about output from my GET requests, does my request for getting sourcemaps mean that they are not in apm-server as value for "hits": is 0 ?

Thank you for advice Juan.

---

<div class="post-metadata">

**Author:** ![jalvz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jalvz/32/45613_2.png) [@jalvz](https://discuss.elastic.co/u/jalvz)\
**Post date:** [August 14, 2020, 8:50am UTC](https://discuss.elastic.co/t/sourcemaps-are-not-getting-applied/244679/6 "2020-08-14T08:50:21Z")

</div>

So the way it works is that you use the APM Server Sourcemap API linked above to `POST` sourcemaps to APMServer. APM Server will validate them and index the in Elasticsearch.  
So yes, if you `GET` request to search sourcemaps in Elasticsearch returns 0 hits, it means that something went wrong and nothing was uploaded. That might be because e.g. a connection problem between APM Server and Elasticsearch, or a validation failure (like no service version given).

Once you have a correct sourcemap uploaded, errors coming from then on will have readable stack traces. But the fix is not retroactive: you won't be able to see stack traces from errors ingested _before_ the sourcemap has been uploaded.

I hope that makes sense.

---

<div class="post-metadata">

**Author:** ![Hamunaptroid](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hamunaptroid/32/63795_2.png) [@Hamunaptroid](https://discuss.elastic.co/u/Hamunaptroid)\
**Post date:** [August 20, 2020, 7:16am UTC](https://discuss.elastic.co/t/sourcemaps-are-not-getting-applied/244679/7 "2020-08-20T07:16:42Z")

</div>

Hello Juan,

You are the absolute King.  
Error "cannot apply sourcemaps" dissappeared.

I have also found out that our source maps don't have mappings, therefore they can't be uploaded to apm-server. But this is not elastic issue, Long story short - it is issue during generation sourcemaps. (with wrong JS version as I was told by our devs).

I was looking for a root cause for this for a pretty long time, so your advice was extremely helpful.

Thank you very much.

---

<div class="post-metadata">

**Author:** ![jalvz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jalvz/32/45613_2.png) [@jalvz](https://discuss.elastic.co/u/jalvz)\
**Post date:** [August 21, 2020, 8:13am UTC](https://discuss.elastic.co/t/sourcemaps-are-not-getting-applied/244679/8 "2020-08-21T08:13:34Z")

</div>

Hello,

Happy to hear you figured it out. Let me know if new issues arise!

---

<div class="post-metadata">

**Author:** ![Hamunaptroid](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hamunaptroid/32/63795_2.png) [@Hamunaptroid](https://discuss.elastic.co/u/Hamunaptroid)\
**Post date:** [August 26, 2020, 9:32am UTC](https://discuss.elastic.co/t/sourcemaps-are-not-getting-applied/244679/9 "2020-08-26T09:32:13Z")

</div>

Hello again Juan,  
It seems like issue is not fixed after all ☹

I want to check if sourcemaps were correctly uploaded this time (after I manually uploaded them and got no errors during uploading). When I try to check them in in Kibana, I get error  
"Too much recursion"

* * *

```
GET apm-*/_search
{
  "query": {
    "term": {
      "processor.event": "sourcemaps"
    }
  }
}

```

Errors look like this:  
Dev Tools Console output  
Unknown Request Error  
too much recursion

```
expandLiteralStrings@http://muhServer.pls.work:5601/31997/bundles/plugin/esUiShared/esUiShared.plugin.js:1:794297
EditorOutputUI/<@http://muhServer.pls.work:5601/31997/bundles/plugin/console/2.plugin.js:1:393171
fs@http://muhServer.pls.work:5601/31997/bundles/kbn-ui-shared-deps/kbn-ui-shared-deps.js:342:77781
Ml@http://muhServer.pls.work:5601/31997/bundles/kbn-ui-shared-deps/kbn-ui-shared-deps.js:342:102513
__kbnSharedDeps__ </t.unstable_runWithPriority@http://muhServer.pls.work:5601/31997/bundles/kbn-ui-shared-deps/kbn-ui-shared-deps.js:350:3462
Hi@http://muhServer.pls.work:5601/31997/bundles/kbn-ui-shared-deps/kbn-ui-shared-deps.js:342:45442
wl@http://muhServer.pls.work:5601/31997/bundles/kbn-ui-shared-deps/kbn-ui-shared-deps.js:342:102276
ol@http://muhServer.pls.work:5601/31997/bundles/kbn-ui-shared-deps/kbn-ui-shared-deps.js:342:87214
Gi/<@http://muhServer.pls.work:5601/31997/bundles/kbn-ui-shared-deps/kbn-ui-shared-deps.js:342:45733
__kbnSharedDeps__ </t.unstable_runWithPriority@http://muhServer.pls.work:5601/31997/bundles/kbn-ui-shared-deps/kbn-ui-shared-deps.js:350:3462
Hi@http://muhServer.pls.work:5601/31997/bundles/kbn-ui-shared-deps/kbn-ui-shared-deps.js:342:45442
Gi@http://muhServer.pls.work:5601/31997/bundles/kbn-ui-shared-deps/kbn-ui-shared-deps.js:342:45680
Yi@http://muhServer.pls.work:5601/31997/bundles/kbn-ui-shared-deps/kbn-ui-shared-deps.js:342:45613
el@http://muhServer.pls.work:5601/31997/bundles/kbn-ui-shared-deps/kbn-ui-shared-deps.js:342:84080
Aa@http://muhServer.pls.work:5601/31997/bundles/kbn-ui-shared-deps/kbn-ui-shared-deps.js:342:62991
_callee$@http://muhServer.pls.work:5601/31997/bundles/plugin/console/2.plugin.js:1:256432
l@http://muhServer.pls.work:5601/31997/bundles/kbn-ui-shared-deps/kbn-ui-shared-deps.js:288:969217
s/o._invoke</<@http://muhServer.pls.work:5601/31997/bundles/kbn-ui-shared-deps/kbn-ui-shared-deps.js:288:968971
_/</e[t]@http://muhServer.pls.work:5601/31997/bundles/kbn-ui-shared-deps/kbn-ui-shared-deps.js:288:969574
asyncGeneratorStep@http://muhServer.pls.work:5601/31997/bundles/plugin/console/2.plugin.js:1:254090
_next@http://muhServer.pls.work:5601/31997/bundles/plugin/console/2.plugin.js:1:254419

```

in addition, new indices are now being named only as (for example) "`apm-7.8.0-2020-26.08`" instead of them having some specification what exactly it is ... (error, transaction, span ...).

...

Have you ever seen anything like this?

Thank you.

---

<div class="post-metadata">

**Author:** ![jalvz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jalvz/32/45613_2.png) [@jalvz](https://discuss.elastic.co/u/jalvz)\
**Post date:** [August 27, 2020, 12:16pm UTC](https://discuss.elastic.co/t/sourcemaps-are-not-getting-applied/244679/10 "2020-08-27T12:16:31Z")

</div>

Hello,

As for the crash: you are hitting [https://github.com/elastic/kibana/pull/72628](https://github.com/elastic/kibana/pull/72628), that will be fixed in 7.9.1 I believe. In the meanwhile, go to the settings tab in the console and disable the option saying "Use triple quotes in output pane".

As for the index names. Can you recall what changed since the indices had the right names? Did you redeploy apm-server, updated apm-server or agent version, etc?  
Running `apm-server -e setup template` should hopefully get it back on track.

Hope that helps!

---

<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:** [September 17, 2020, 8:16am UTC](https://discuss.elastic.co/t/sourcemaps-are-not-getting-applied/244679/11 "2020-09-17T08:16:37Z")

</div>

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