Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

小程序 Taro.onError 没有触发,无法捕获JS错误 #11552

Closed
uujx opened this issue Mar 31, 2022 · 9 comments
Closed

小程序 Taro.onError 没有触发,无法捕获JS错误 #11552

uujx opened this issue Mar 31, 2022 · 9 comments
Labels
F-react Framework - React T-tt Target - 编译到字节跳动小程序 V-3 Version - 3.x
Milestone

Comments

@uujx
Copy link

uujx commented Mar 31, 2022

相关平台

字节跳动小程序

小程序基础库: 1.9.58.4
使用框架: React

复现步骤

  1. 小程序入口文件 app.js 中,在 useEffect 中添加 Taro.onError(e => console.log(e));
  2. 代码中手动制造 JS 错误

期望结果

onError触发,打印 error message

实际结果

onError没有触发,没有打印 error message

环境信息

Taro CLI 3.3.20 environment info:
    System:
      OS: macOS 11.6.4
      Shell: 5.8 - /bin/zsh
    Binaries:
      Node: 12.18.3 - ~/.nvm/versions/node/v12.18.3/bin/node
      Yarn: 1.22.10 - /usr/local/bin/yarn
      npm: 7.6.3 - ~/.nvm/versions/node/v12.18.3/bin/npm
    npmPackages:
      @tarojs/cli: 3.4.3 => 3.4.3 
      @tarojs/components: 3.4.3 => 3.4.3 
      @tarojs/mini-runner: 3.4.3 => 3.4.3 
      @tarojs/plugin-platform-tt: 3.4.3 => 3.4.3 
      @tarojs/react: 3.4.3 => 3.4.3 
      @tarojs/runtime: 3.4.3 => 3.4.3 
      @tarojs/taro: 3.4.3 => 3.4.3 
      @tarojs/webpack-runner: 3.4.3 => 3.4.3 
      babel-preset-taro: 3.4.3 => 3.4.3 
      eslint-config-taro: 3.4.3 => 3.4.3 
      react: 16.14.0 => 16.14.0 
    npmGlobalPackages:
      typescript: 4.4.4
@taro-bot2 taro-bot2 bot added F-react Framework - React T-tt Target - 编译到字节跳动小程序 V-3 Version - 3.x labels Mar 31, 2022
@Chen-jj Chen-jj added this to the 3.5.0 milestone Jun 6, 2022
@Chen-jj
Copy link
Contributor

Chen-jj commented Jun 6, 2022

Taro v3.5 开始支持

@Chen-jj Chen-jj closed this as completed Jun 6, 2022
@wuweikd
Copy link

wuweikd commented May 6, 2023

3.6.5 版本,支付宝小程序开发者工具,手动throw new Error("测试");

Taro.onError((e) => {
  console.warn('onError!:', e)
})

Taro.onError不能捕获错误

@doudou673
Copy link

现在解决了吗?

@Casey-ckx
Copy link

所以现在解决了吗

@Casey-ckx
Copy link

Taro v3.5 开始支持

我试了一下 3.6都没有捕获成功 对于小程序js报错收集这块我们有诉求但是不知道有什么方式可以收集

@Chen-jj
Copy link
Contributor

Chen-jj commented Nov 8, 2023

3.6.5 版本,支付宝小程序开发者工具,手动throw new Error("测试");

Taro.onError((e) => {
  console.warn('onError!:', e)
})

Taro.onError不能捕获错误

@wuweikd 测试了一下,支付宝开发者工具是监听不了的,真机可以,应该是开发者工具自身问题导致。

@Casey-ckx
Copy link

Casey-ckx commented Nov 8, 2023 via email

@Chen-jj
Copy link
Contributor

Chen-jj commented Nov 8, 2023

Taro v3.5 开始支持

我试了一下 3.6都没有捕获成功 对于小程序js报错收集这块我们有诉求但是不知道有什么方式可以收集

试了 3.6.18,可以监听成功:

image

image

@xavieryang2011
Copy link

报错那加了4s延时,不加延时是不是也不行啊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-react Framework - React T-tt Target - 编译到字节跳动小程序 V-3 Version - 3.x
Projects
None yet
Development

No branches or pull requests

6 participants