[Node] Background task, transaction.end() taking long time to complete

https://onenr.io/0YBR6r4v0RO

[Revisiting this issue - Transaction.end() taking a long time to complete]

Hi

I am trying out the non-web transaction feature in our project for tracking, using the following functions ‘startBackgroundTransaction’ and transaction.end() to start and end respectively. I am seeing that for long running tasks (with a lot of DB and network interactions happening, usually 10 minutes or more), the newrelic agent doesn’t end the background process, it takes a long time to complete or just keeps the calling task waiting. Also, on the UI i do not see the transaction traces.
With shorter running tasks, I don’t see this issue, the background process is completed, I am able to look at the transaction traces on the UI.

We are looking forward to adding this feature, let me know if you need any other info. I am happy to share it.

npm “newrelic”: “8.6.0”
“nodejs”: “v12.19.0”

Regards

Hey there @chet.aery,

Thanks for reaching out to the New Relic Community! I think I might be able to shed some light on your situation here. I’ve included some docs that I think may solve your issues. The first one is an overview of the process that you want to use here. Language agents and distributed tracing | New Relic Documentation

The next one is a deep dive into the startBackgroundTransaction call and all of it’s related processes. Node.js agent API | New Relic Documentation

I really hope this info helps and please don’t hesitate to reach out if you have any questions or extra details to add.

Cheers