我正在尝试调试NodeJs AWS Lambda上非常罕见且随机的超时。 要查看哪些进程仍在运行,我将使用该线程How can I get a list of callbacks in the Node work queue? (or, Why won't Node exit?)中的程序包。 为了避免无用的日志,我只想在运行500毫秒以上的过程中记录回调。 有可能这样做吗? 谢谢
答案 0 :(得分:2)
我会用类似的东西
var to = setTimeout(function(){ <log> }, 500); //log in 500ms
然后在命令末尾可以执行以下操作:
clearTimeout(to);
这样,除非持续时间少于500秒并调用cleartimeout,否则它将调用日志半秒。