# Unable to track errors with elastic-apm-node in Nextjs App

**URL:** <https://discuss.elastic.co/t/unable-to-track-errors-with-elastic-apm-node-in-nextjs-app/333257>\
**Category:** APM\
**Tags:** nodejs\
**Created:** [May 12, 2023, 6:00am UTC](https://discuss.elastic.co/t/unable-to-track-errors-with-elastic-apm-node-in-nextjs-app/333257 "2023-05-12T06:00:58Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![prakashks](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/prakashks/32/120908_2.png) [@prakashks](https://discuss.elastic.co/u/prakashks)\
**Post date:** [May 12, 2023, 6:00am UTC](https://discuss.elastic.co/t/unable-to-track-errors-with-elastic-apm-node-in-nextjs-app/333257/1 "2023-05-12T06:00:58Z")

</div>

**APM Server version** :  
8.71

**APM Agent language and version** :  
3

**Browser version** :  
Chrome 112

**Original install method (e.g. download page, yum, deb, from source, etc.) and version**:  
yarn add elastic-apm-node

**Fresh install or upgraded from other version?**  
Fresh install

**Is there anything special in your setup?**  
No special setup for my side

**Description of the problem including expected versus actual behavior. Please include screenshots (if relevant)**:  
Runtime scripts errors are not tracked in Elastic APM.

**Steps to reproduce** :

1. Runtime errors are shown in the browser console
2. Browser consoles are not tracked in Elastic APM
3. It's only tracking the Nextjs app core hydration issue only.

**Errors in browser console (if relevant)**:  
Failed to load resource: the server responded with a status of 404 (Not Found)

next-dev.js:20 Error: Cannot read properties of undefined (reading 'length')

**Provide logs and/or server output (if relevant)**:

---

<div class="post-metadata">

**Author:** ![trentm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/trentm/32/77647_2.png) [@trentm](https://discuss.elastic.co/u/trentm)\
**Post date:** [May 12, 2023, 6:58pm UTC](https://discuss.elastic.co/t/unable-to-track-errors-with-elastic-apm-node-in-nextjs-app/333257/2 "2023-05-12T18:58:31Z")

</div>

Hi @prakashks, thanks for the question.

I'd need more details (full log output, full stacktrace from that `Cannot read properties of undefined (reading 'length')` error) to be able to help figure out what the issue is.

---

<div class="post-metadata">

**Author:** ![prakashks](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/prakashks/32/120908_2.png) [@prakashks](https://discuss.elastic.co/u/prakashks)\
**Post date:** [May 15, 2023, 4:52am UTC](https://discuss.elastic.co/t/unable-to-track-errors-with-elastic-apm-node-in-nextjs-app/333257/3 "2023-05-15T04:52:52Z")

</div>

@trentm The issue occurred when checking the data length at run time(Data value is undefined at runtime).

---

<div class="post-metadata">

**Author:** ![prakashks](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/prakashks/32/120908_2.png) [@prakashks](https://discuss.elastic.co/u/prakashks)\
**Post date:** [May 22, 2023, 4:12am UTC](https://discuss.elastic.co/t/unable-to-track-errors-with-elastic-apm-node-in-nextjs-app/333257/4 "2023-05-22T04:12:07Z")

</div>

@trentm Any update?

---

<div class="post-metadata">

**Author:** ![trentm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/trentm/32/77647_2.png) [@trentm](https://discuss.elastic.co/u/trentm)\
**Post date:** [May 23, 2023, 10:02pm UTC](https://discuss.elastic.co/t/unable-to-track-errors-with-elastic-apm-node-in-nextjs-app/333257/5 "2023-05-23T22:02:16Z")

</div>

@prakashks Just that one line of log output isn't enough for me to try to determine where the error could be. Can you provide a more complete log file of the running app?

At a minimum, can you show the full stacktrace? This would be a number of lines before and/or after the `next-dev.js:20 Error: Cannot read properties of undefined (reading 'length')` line.

Ideally you could send full trace-level log output from elastic-apm-node while running your app. You can turn trace-level logging on as described here: [Troubleshooting | APM Node.js Agent Reference [3.x] | Elastic](https://www.elastic.co/guide/en/apm/agent/nodejs/current/troubleshooting.html#debug-mode)

---

<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:** [June 13, 2023, 6:02pm UTC](https://discuss.elastic.co/t/unable-to-track-errors-with-elastic-apm-node-in-nextjs-app/333257/6 "2023-06-13T18:02:38Z")

</div>

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