# Error while using Elastic node APM with database transactions

**URL:** <https://discuss.elastic.co/t/error-while-using-elastic-node-apm-with-database-transactions/376519>\
**Category:** APM\
**Tags:** nodejs\
**Created:** [March 28, 2025, 10:56am UTC](https://discuss.elastic.co/t/error-while-using-elastic-node-apm-with-database-transactions/376519 "2025-03-28T10:56:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![David\_Souza](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/david_souza/32/142307_2.png) [@David\_Souza](https://discuss.elastic.co/u/David_Souza)\
**Post date:** [March 28, 2025, 10:56am UTC](https://discuss.elastic.co/t/error-while-using-elastic-node-apm-with-database-transactions/376519/1 "2025-03-28T10:56:16Z")

</div>

**Description** :  
I am using elastic-apm-node to instrument a nestjs API it works perfectly, some weeks ago I needed to added database transactions using sequelize and I got the following error

I tested and If I remove database transactions it works correctly and not show this error.

I tried to search on the forums and and tried a lot of ways to solve this problem, but nothing works.

Thank you in advance!!

---

<div class="post-metadata">

**Author:** ![David\_Luna\_Bistuer](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/david_luna_bistuer/32/122147_2.png) [@David\_Luna\_Bistuer](https://discuss.elastic.co/u/David_Luna_Bistuer)\
**Post date:** [March 28, 2025, 2:40pm UTC](https://discuss.elastic.co/t/error-while-using-elastic-node-apm-with-database-transactions/376519/6 "2025-03-28T14:40:50Z")

</div>

Hi @David_Souza ,

the API to start manual spans belongs to the transaction class as shown in [Transaction API | APM Node.js Agent Reference [4.x] | Elastic](https://www.elastic.co/guide/en/apm/agent/nodejs/current/transaction-api.html#transaction-start-span). So you need to use such API in the ongoing transaction and the way of getting it is via [apm.currentTransaction property](https://www.elastic.co/guide/en/apm/agent/nodejs/current/agent-api.html#apm-current-transaction).

By the code snippet given and knowing you're using NestJS I guess you're passing the `apm` instance through the injector by wrapping it with a module or service, right? If so I would ask

- How you're starting the NestJS app
- what exactly is the property `Apm.context`?
- Could you share the `apm` wrapper module?

Cheers,  
David

---

<div class="post-metadata">

**Author:** ![David\_Souza](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/david_souza/32/142307_2.png) [@David\_Souza](https://discuss.elastic.co/u/David_Souza)\
**Post date:** [April 22, 2025, 3:55pm UTC](https://discuss.elastic.co/t/error-while-using-elastic-node-apm-with-database-transactions/376519/9 "2025-04-22T15:55:05Z")

</div>

@David_Luna_Bistuer
