Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migration from CLS to CLS-hooked time outs requests #41

Open
zatziky opened this issue Apr 8, 2019 · 1 comment
Open

Migration from CLS to CLS-hooked time outs requests #41

zatziky opened this issue Apr 8, 2019 · 1 comment

Comments

@zatziky
Copy link

zatziky commented Apr 8, 2019

I don't know how to describe this issue and hope that you'll give me some hints of what is going on. Any, really any hints are highly appreciated as I can't debug the app to give me any useful info whatsoever. (It seems like a limit in my skills. :)

Background

Since we are using async/await, in our logging lib we have migrated from CLS to CLS-hooked. It fixed the context and we could reach any values needed again. However, when running tests, they started to time-out and the overall app started to react strangely.

All the migration meant only replacement of const continuationStorage = require('continuation-local-storage') // v3.2.1 for const continuationStorage = require('cls-hooked') // v4.2.2.

Node Versions tested

We have tested against these versions:

  • Node 10.14.2
  • Node 11.2.0

How do we use CLS?

  1. This file takes care of context creation. An excerpt:
const continuationStorage = require('cls-hooked')

const createNamespace = continuationStorage.createNamespace
const getNamespace = continuationStorage.getNamespace

const NSP_REQUEST = 'logzio-node-debug-request'
const KEY_MDC = 'mdc'
const requestNamespace = createNamespace(NSP_REQUEST)

function createContext(next) {
  const mdc = getAll()
  const mdcCopy = Object.assign({}, mdc)
  requestNamespace.run(() => {
    requestNamespace.set(KEY_MDC, mdcCopy)
    next()
  })
}
  1. We create a new context for every incoming request. We're using socket.io
// MDC i
const MDC = require('logzio-node-debug').MDC 

socket.use((packet, next) => {
      MDC.createContext(() => {
        MDC.put('key', 'value')
        next()
      })
    })
  1. We also put other values during code execution:
const MDC = require('logzio-node-debug').MDC 
MDC.put('key2', 'value2')

Question

Is this a bug? Are we doing something wrong?

@zatziky
Copy link
Author

zatziky commented Apr 8, 2019

I managed to identify that the problems happen only with database tests. We are using mysqljs/mysql. Is it possible that it handles queueing improperly?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant