Open 15335179243 opened 2 years ago
我想知道同时发送多条视频是同步还是异步,异步的话怎么样能够就行同步发送
18:12:06 ERR PuppetWeChat uploadMedia(): upload fail
18:12:06 ERR PuppetWeChat sendMedia() exception: PuppetWeChat.uploadMedia(): upload fail
finis Caught exception: Error: PuppetWeChat.uploadMedia(): upload fail
at PuppetWeChat.uploadMedia (/wechaty/node_modules/wechaty-puppet-wechat/dist/cjs/src/puppet-wechat.js:1223:19)
at runMicrotasks (
@huan 这个问题能不能解决,或者避免,我们也很需要您的帮助
In order to solve a crash problem, we need reproducible steps, with minimum source code.
If you can provide it, then I believe our community would be very happy to see what happened in the case.
关键源码 const roomList = await bot.Room.findAll({ topic: resJson['机器人测试群'] }) roomList[0].say(FileBox.fromUrl('https://media.w3.org/2010/05/sintel/trailer.mp4')) 他崩溃也是有一定概率的,有时候发一条就崩溃了,有时候发两条 @他这个崩溃是崩溃到sdk底层了,我们在上层应用程序也无法捕捉
@huan ├── wechaty-grpc@0.27.12 extraneous -> ./wechaty/node_modules/wechaty-grpc ├── wechaty-puppet-mock@0.31.8 extraneous -> ./wechaty/node_modules/wechaty-puppet-mock ├── wechaty-puppet-service@0.31.26 extraneous -> ./wechaty/node_modules/wechaty-puppet-service ├── wechaty-puppet-wechat@0.30.6 extraneous -> ./wechaty/node_modules/wechaty-puppet-wechat ├── wechaty-puppet@0.43.13 extraneous -> ./wechaty/node_modules/wechaty-puppet ├── wechaty-token@0.5.8 extraneous -> ./wechaty/node_modules/wechaty-token ├── wechaty@0.69.17 extraneous -> ./wechaty
In order to solve a crash problem, we need:
If there's no minimum reproducible code & steps, then we will not be able to inspect the problem.
@huan 我制作了一个demo,我怎么把源码个到你
10:41:03 VERB PuppetWeChat uploadMedia() webwx_data_ticket: gSdMobaHqSZQt4PpbioWK1JO
10:41:03 VERB PuppetWeChat uploadMedia() pass_ticket: undefined
10:41:05 ERR PuppetWeChat uploadMedia(): upload fail
10:41:05 ERR PuppetWeChat sendMedia() exception: PuppetWeChat.uploadMedia(): upload fail
10:41:05 ERR Config ###########################
10:41:05 ERR Config unhandledRejection: Error: PuppetWeChat.uploadMedia(): upload fail
at PuppetWeChat.uploadMedia (/wechaty/node_modules/wechaty-puppet-wechat/dist/src/puppet-wechat.js:1204:19)
at runMicrotasks (
运行demo你会看到这样的错误 @huan
You can publish your demo with source code to a GitHub repo, so that our community can see it.
@huan 这个问题的相关代码我已经开源到GitHub了,我这边测试问题是可以复现的,https://github.com/15335179243/WechatUploadBug
@huan 想必你跑过代码后,你已经看到那个问题了,是否有什么解决方案
You can try to follow the below change and to see if it helps:
if (index <= list.length-1) {
- roomList[0].say(FileBox.fromUrl(list[index]))
+ await roomList[0].say(FileBox.fromUrl(list[index]))
+ await bot.sleep(10 * 1000) // sleep 10 seconds
index++
}
The above code change solves that, we need to wait for each video to be sent before we send the next one.
You can test with a web browser to using the web wechat, and send 20+ video files at the same time, then you will be able to see most of the file sending task will fail with 红色感叹号.
@huan 我们发送视频也不是同事发送20条,我们一共不到十条,每条之间间隔有5分钟,每条视频也不超过20m,但是他有的时候发送第一条就会出现问题,我看了一下web版的微信,他上传是能拿到进度的,我们可否也能获取到进度?
有的时候发送第一条就会出现问题
It's very hard to analyze the problem if your problem can not reproduce every time.
我看了一下web版的微信,他上传是能拿到进度的,我们可否也能获取到进度?
Yes, we can.
However, I think our code has not supported that yet, and I'd like to accept a PR with progress design for it.
@huan 我认为这个失败问题,我们应该进行异常捕捉并进行接口回调,当接口回调以后我们再做下一步操作,是不是这样会友好一点
Your suggestion looks good.
However, whether it is a real good solution will be highly dependent on the implementation source code.
I'd like to review a PR for improving it.
error: Error: aborted at connResetException (node:internal/errors:691:14) at Socket.socketCloseListener (node:_http_client:407:19) at Socket.emit (node:events:402:35) at Socket.emit (node:domain:475:12) at TCP. (node:net:687:12) {
code: 'ECONNRESET'
}
finis Caught exception: Error: aborted
at connResetException (node:internal/errors:691:14)
at Socket.socketCloseListener (node:_http_client:407:19)
at Socket.emit (node:events:402:35)
at Socket.emit (node:domain:475:12)
at TCP. (node:net:687:12) {
code: 'ECONNRESET'
} Exception origin: uncaughtException
16:03:34 ERR Importand data saved at this step.
16:03:34 ERR Wechaty exit 99 because of uncaughtException/Error: aborted
发送了四条视频,其中三条没有超过20m,一条为28m,三条成功了,一条失败