收藏
回答

miniprogram-automator 截图失败

框架类型 问题类型 操作系统 工具版本
小程序 Bug macOS RC 1.03.2006091

确定开发环境没有问题,因为本来可以截图,后来突然开始报错,重启开发者工具甚至重启电脑都没用。使用 node repl 就可以复现,但只在我的电脑上有问题,由于问题与代码无关,无法提供复现步骤。

报错内容:Error: fail to capture screenshot 操作步骤与详细报错如下。

> const automator = require('miniprogram-automator')
undefined
> automator.launch({
... projectPath:
... '/Users/username/dev/wxa-dcp/dist'
... }).then(mpp => global.mpp = mpp)
Promise { <pending> }

# 不带 options 报错

> mpp.screenshot()
Promise { <pending> }
> (node:4886) UnhandledPromiseRejectionWarning: Error: fail to capture screenshot
    at Transport.Connection.onMessage (/Users/username/dev/temp/test-project/node_modules/miniprogram-automator/out/Connection.js:1:986)
    at Transport.emit (events.js:315:20)
    at Transport.EventEmitter.emit (domain.js:505:15)
    at WebSocket.<anonymous> (/Users/username/dev/temp/test-project/node_modules/miniprogram-automator/out/Transport.js:1:219)
    at WebSocket.onMessage (/Users/username/dev/temp/test-project/node_modules/miniprogram-automator/node_modules/ws/lib/event-target.js:120:16)
    at WebSocket.emit (events.js:315:20)
    at WebSocket.EventEmitter.emit (domain.js:505:15)
    at Receiver.receiverOnMessage (/Users/username/dev/temp/test-project/node_modules/miniprogram-automator/node_modules/ws/lib/websocket.js:789:20)
    at Receiver.emit (events.js:315:20)
    at Receiver.EventEmitter.emit (domain.js:505:15)
(node:4886) UnhandledPromiseRejectionWarning: Unhandled promise rejection. 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(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:4886) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

# 带 options 也报错,指定目录无权限问题

> mpp.screenshot({path: '/Users/username/Desktop/aaa.png'})
Promise { <pending> }
> (node:4886) UnhandledPromiseRejectionWarning: Error: fail to capture screenshot
    at Transport.Connection.onMessage (/Users/username/dev/temp/test-project/node_modules/miniprogram-automator/out/Connection.js:1:986)
    at Transport.emit (events.js:315:20)
    at Transport.EventEmitter.emit (domain.js:505:15)
    at WebSocket.<anonymous> (/Users/username/dev/temp/test-project/node_modules/miniprogram-automator/out/Transport.js:1:219)
    at WebSocket.onMessage (/Users/username/dev/temp/test-project/node_modules/miniprogram-automator/node_modules/ws/lib/event-target.js:120:16)
    at WebSocket.emit (events.js:315:20)
    at WebSocket.EventEmitter.emit (domain.js:505:15)
    at Receiver.receiverOnMessage (/Users/zhangchaofan/dev/temp/test-project/node_modules/miniprogram-automator/node_modules/ws/lib/websocket.js:789:20)
    at Receiver.emit (events.js:315:20)
    at Receiver.EventEmitter.emit (domain.js:505:15)
(node:4886) UnhandledPromiseRejectionWarning: Unhandled promise rejection. 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(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 3)
回答关注问题邀请回答
收藏

1 个回答

  • RedHood
    RedHood
    2020-06-11

    基础库版本是什么?清除工具缓存试下

    2020-06-11
    有用
    回复 3
    • 超凡
      超凡
      2020-06-11
      2.9.4 清除缓存后可以了,但是这个问题是怎么导致的,会不会自动化脚本跑久了出问题就要手动清一次。这就成半自动了啊。。。不会再加个清除缓存的接口吧😂
      2020-06-11
      回复
    • RedHood
      RedHood
      2020-06-11回复超凡
      之前的实现有问题,2.11.1 版本修复了
      2020-06-11
      回复
    • 超凡
      超凡
      2020-06-11回复RedHood
      好的了解了🙏
      2020-06-11
      回复
登录 后发表内容
问题标签