我有一个使用异步主方法的Node.js脚本。有时脚本能够正常终止,但有时会出现挂起的情况。
const main = async () => {
let updates = []
// ... add a bunch of promises to updates
await Promise.all(updates)
}
main()
有人知道为什么这个脚本有时会停顿吗?虽然它似乎已经运行完成,但它并没有终止。
我有一个使用异步主方法的Node.js脚本。有时脚本能够正常终止,但有时会出现挂起的情况。
const main = async () => {
let updates = []
// ... add a bunch of promises to updates
await Promise.all(updates)
}
main()
有人知道为什么这个脚本有时会停顿吗?虽然它似乎已经运行完成,但它并没有终止。
process.exit()
的情况下。 - Paulmain().then(() => process.exit())
,它应该总是终止。 - axanpi