Javen205 / TNWX

TNWX: TypeScript + Node.js + WeiXin 微信系开发脚手架,支持微信公众号、微信支付、微信小游戏、微信小程序、企业微信/企业号。最最最重要的是能快速的集成至任何 Node.js 框架(Express、Nest、Egg、Koa 等)
Apache License 2.0
642 stars 97 forks source link

isAvailable 传入参数为空时未处理 #36

Closed Dream4ever closed 3 years ago

Dream4ever commented 3 years ago

版本信息

报错信息 (注意格式化)

SyntaxError: Unexpected end of JSON input
    at JSON.parse (<anonymous>)
    at Function.isAvailable (E:\upcweb\apicenter\node_modules\@tnwx\commons\dist\api\JsTicketApi.js:64:29)
    at Function.<anonymous> (E:\upcweb\apicenter\node_modules\@tnwx\commons\dist\api\JsTicketApi.js:34:38)
    at Generator.next (<anonymous>)
    at fulfilled (E:\upcweb\apicenter\node_modules\@tnwx\commons\dist\api\JsTicketApi.js:10:58)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)

问题描述(包括回显步骤、截图 )

首先非常感谢作者发布的这个框架,太好用了!哈哈。

我是在项目中第一次接入这个框架,在使用 WeChat.jssdkSignature 这个方法时,发现调用始终不成功,报错代码如上所示。

经过多次 debug,发现是 JsTicketApi.js 中的 isAvailable 这个方法,没有对传入参数为空的情况进行处理。遗憾的是我不知道该如何复现这个 bug,只是在我的测试环境中会有这个 bug。

我用的临时的解决办法,是在 JsTicketApi.js 中的 isAvailable 这个方法里,先判断传入参数是否为空,为空则直接返回 false。之后再调用 WeChat.jssdkSignature,就一切正常了。

Dream4ever commented 3 years ago

刚发现 dev 分支里已经对这个情况进行处理了 @_@ https://github.com/Javen205/TNWX/compare/dev#diff-48291fbfa0f5651864d4a9165daa9d0f283d71fdc43954c3efb4865c5e7e8fbfR57