Tencent / TSW

Tencent Server Web

Home Page:https://tswjs.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

2.0 启动报错:TypeError: Cannot destructure property `log` of 'undefined' or 'null'.

JohannLai opened this issue · comments

复现代码步骤:

把下面 example 这一行加一个 host 的参数即可复现:

}).listen(4443);

也就是这样会报错:

app.listen(4443, '0.0.0.0')

但是 这样是正常的

app.listen(4443) 

报错详细内容如下:

This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason: []
TypeError: Cannot destructure property `log` of 'undefined' or 'null'.
    at Function.getLog (/data/workSpace/***h/node_modules/@tswjs/tsw/dist/core/logger/index.js:127:42)
    at Function.formatStr (/data/workSpace***h/node_modules/@tswjs/tsw/dist/core/logger/index.js:100:43)
    at Logger.writeLog (/data/workSpace/***h/node_modules/@tswjs/tsw/dist/core/logger/index.js:67:31)
    at Logger.debug (/data/workSpace/***h/node_modules/@tswjs/tsw/dist/core/logger/index.js:43:14)
    at dns.lookup (/data/workSpace/***h/node_modules/@tswjs/tsw/dist/core/runtime/dns.hack.js:34:30)
    at net.js:1003:5
    at defaultTriggerAsyncIdScope (internal/async_hooks.js:294:19)
    at lookupAndConnect (net.js:1002:3)
    at Socket.connect (net.js:937:5)
    at Object.connect (net.js:156:17) []
This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason: []
^C

麻烦看看~ 🌹

是个 bug,配置了 hostname 会先去调用一次 dnsLookup 解析域名,而 TSW 对 dns 做了 hack,导致了非预期的自循环。