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 3.0.2 版本中,若在Taro.getStorage中已配置有 fail 对应处理函数,为什么在微信调试工具里还会报 MiniProgramError {"errMsg":"getStorage:fail data not found"}相关错误 #6984

Closed
puxiao opened this issue Jul 9, 2020 · 11 comments
Labels
F-react Framework - React T-weapp Target - 编译到微信小程序 V-3 Version - 3.x

Comments

@puxiao
Copy link

puxiao commented Jul 9, 2020

相关平台

微信小程序

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

复现步骤

 Taro.getStorage({
            key: 'xxx',
            success: (res) => {
                console.log(res)
            },
            fail: (res) => {
                console.log(res)
            }
        })

其中 数据缓存中并不存在 xxx ( 此时会引发读取失败),那么我希望既然都设定有 fail 处理函数,微信调试工具里就不要再报错误了。

莫非必须使用 try catch 才可以解决这个问题吗?

期望结果

我希望如果配置有 fail 处理函数,那么当读取失败时就不要再报错误了。

实际结果

微信调试工具里,若遇到读取数据缓存错误,则会报:
(in promise) MiniProgramError
{"errMsg":"getStorage:fail data not found"}
Object

环境信息

Taro CLI 3.0.2 environment info:
    System:
      OS: Windows 7
    Binaries:
      Node: 12.13.0 - D:\Program Files\nodejs\node.EXE
      npm: 6.14.2 - D:\Program Files\nodejs\npm.CMD
@taro-bot2 taro-bot2 bot added F-react Framework - React T-weapp Target - 编译到微信小程序 V-3 Version - 3.x labels Jul 9, 2020
@puxiao puxiao changed the title Taro 3.0.2 版本中,若在Taro.getStorage中已配置有 fail 对应处理函数,为什么在微信调试工具里还会报错误事件 MiniProgramError {"errMsg":"getStorage:fail data not found"}相关错误 Taro 3.0.2 版本中,若在Taro.getStorage中已配置有 fail 对应处理函数,为什么在微信调试工具里还会报 MiniProgramError {"errMsg":"getStorage:fail data not found"}相关错误 Jul 9, 2020
@Chen-jj
Copy link
Contributor

Chen-jj commented Jul 9, 2020

@puxiao 试试直接使用 wx.getStorage 看看吧,感觉是小程序的问题

@Chen-jj
Copy link
Contributor

Chen-jj commented Jul 16, 2020

@puxiao Taro.getStorage 把 wx.getStorage promise 化了,返回的 promise reject 的情况下你不 catch 是会报 error,这样写吧:

Taro.getStorage({ key: 'xxx' })
  .then(res => {
    console.log(res)
  }),
  .catch(err => {
     console.log(err)
  })      

@Chen-jj Chen-jj closed this as completed Jul 16, 2020
@molunhui
Copy link

@Chen-jj 升级到3.4.0版本;已经是try catch的,H5环境仍报getStorage:fail data not found
image
看源码,MethodHandler fail方法 打了个error的log..
image

@Chen-jj
Copy link
Contributor

Chen-jj commented Jan 24, 2022

@Phlen 就是 data not found 咯,这是小程序报给你的。

@molunhui
Copy link

@Chen-jj 我知道是对应key没有数据,我的意思是taro不应该替开发者打log啊,而且是error的log;你看不难受吗
image

@Chen-jj
Copy link
Contributor

Chen-jj commented Jan 24, 2022

@Chen-jj 我知道是对应key没有数据,我的意思是taro不应该替开发者打log啊,而且是error的log;你看不难受吗
image

H5 的 Api 一切行为尽量会遵循小程序环境,小程序 Api 这种情况会给你 log error,H5我们去实现这个 api 的时候就会保持同样的行为。

@molunhui
Copy link

@Chen-jj 小程序并没有报这个错误的

@tianyi00tiyan2
Copy link

到现在都没有修复 @Chen-jj 我看了你的回复 你就是在搞笑啊

@yoyo837
Copy link
Contributor

yoyo837 commented Jan 23, 2023

到现在都没有修复 @Chen-jj 我看了你的回复 你就是在搞笑啊

有问题说问题,看上去不被认为是个问题,如果你觉得是,可以细致分析讲清楚,或者直接PR

@xiang12383
Copy link

@Phlen 就是 data not found 咯,这是小程序报给你的。

这个不是小程序的问题,taro 改成 wx,就可以正常走到fail那一步,taro不行,fail回调走不通。这个是taro的问题,希望有空能修复一下呢。

@tianyi00tiyan2
Copy link

到现在都没有修复 @Chen-jj 我看了你的回复 你就是在搞笑啊

有问题说问题,看上去不被认为是个问题,如果你觉得是,可以细致分析讲清楚,或者直接PR

问题 上面的其他同学已经说的很清楚了 确实不是很大的问题 关键是作为框架开发者 回复问题的前提是读了 读懂了 复现了问题

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

No branches or pull requests

6 participants