5

I am using https://github.com/jeff-lewis/cls-hooked for preserving execution context across async callbacks. I see context dropping during the life span of a request.

I am aware of https://github.com/nodejs/diagnostics/blob/master/tracing/AsyncHooks/problematic-modules.md modules that break async continuity.

How can I find out what other modules are breaking my async continuity? The app is a express based node.js server.

Abhishek
  • 1,216
  • 1
  • 9
  • 13

1 Answers1

4

I finally figured out this after I added logging statements throughout my code and realized that context was being dropped at database calls, turns out I was using https://github.com/datastax/nodejs-driver which does connection pooling internally which causes the context drop.

const cassandra = require('cassandra-driver')

let c = new cassandra.Client(// options here...)

c.execute(query, params, options, namespace.bind(function() {
    // This callback will now inherit the right parent context
}))

More information about userland queuing problem:

https://docs.google.com/document/d/1tlQ0R6wQFGqCS5KeIw0ddoLbaSYx6aU7vyXOkv-wvlM/edit https://github.com/othiym23/node-continuation-local-storage/issues/59

Abhishek
  • 1,216
  • 1
  • 9
  • 13
  • 1
    Faced the same issue with mysql db where connection pooling were involved. I have also written my own implementation using async hooks of node js but facing the same issue of context dropping. – sumit_suthar Aug 16 '19 at 10:48