balderdashy/sails

Preserve async hook on call to helper

Open

#6,960 建立於 2020年3月12日

在 GitHub 查看
 (4 留言) (1 反應) (0 負責人)JavaScript (22,778 star) (1,953 fork)batch import
help wantedmore info please

描述

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...

貢獻者指南