【发布时间】:2021-11-01 18:29:18
【问题描述】:
我的代码中有这个模块需要调试。它在一个文件中,我们可以调用 GCP 云调度程序调用的 test.js。
const run = require("../../run");
module.exports = async (req, res) => {
await run(false);
res.send("done");
};
我想记录资源以查看发生了什么。像这样的:
console.log('hello');
module.exports = async (req, res) => {
await run(false);
console.log(res)
res.send("done");
};
console.log('world');
但我没有得到那个console.log。我会得到
hello
world
【问题讨论】:
-
什么意思?
-
提供更多日志
-
更新了问题,抱歉
-
你怎么知道导出的函数实际上被调用了?好像不是。 (或者
await run(false)没有完成,所以你永远不会到达console.log行) -
我很确定console.log(res) 不会在
hello和world之间记录。因为异步代码不会作为同步代码运行。 :)
标签: javascript node.js google-cloud-platform