balderdashy/sails

Preserve async hook on call to helper

Open

#6.960 aberto em 12 de mar. de 2020

Ver no GitHub
 (4 comments) (1 reaction) (0 assignees)JavaScript (1.953 forks)batch import
help wantedmore info please

Métricas do repositório

Stars
 (22.778 stars)
Métricas de merge de PR
 (Mesclagem média 23h 44m) (1 fundiu PR em 30d)

Description

So there is this thing called async hooks in Node now that allow for stuff to be preserved like you would with thread local in other languages. A popular library that uses that is cls-hooked. This is very useful to put trace ID and add that trace to the logs when you want to do distributed logging (or add a user ID to have some context for your logs). However, the machine that powers sails messes up with this process and we lose the information when an helper is called. I am not sure what happens, but it is most likely related to how the machine that powers sails works (by making HTTP calls I believe for each helper). I think @mikermcneil would be the one to answer that since not a lot people seem to have touched this code except him...

Guia do colaborador