Skip to content

Conversation

@jysperm
Copy link
Contributor

@jysperm jysperm commented May 27, 2016

  • AV.Cloud.rpc 方法也需支持 sessionToken 参数,之前是因为 PR 合并顺序的缘故落下了这个函数。
  • disableCurrentUser 的情况下,AV.User.logOut 应该返回一个空的 Promise 而不是 return console.warn();
  • disableCurrentUser 相关的警告只打印一次,以免日志打印过多;并用 console.trace() 打印调用栈,方便找到调用处。

#251

src/user.js Outdated
const AVError = require('./error');
const AVRequest = require('./request').request;

var disableCurrentUserWarning = false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

var -> let

@wangxiao
Copy link
Contributor

disableCurrentUser 相关的警告只打印一次,以免日志打印过多;并用 console.trace() 打印调用栈,方便找到调用处。

这个为什么要只打印一次呢?如果我调用一个有问题的函数,那这个函数只输出了一次错误,这个暴露是不是有点奇怪?

@jysperm
Copy link
Contributor Author

jysperm commented May 27, 2016

因为实际测试的效果就是如果用户的程序中有地方用了 currentUser,将会打印非常大量的警告(可能一个请求会引发好几次警告)。加上这个修改将 warn 换成了 trace(调用栈),所以日志量会更大。

@wangxiao
Copy link
Contributor

因为实际测试的效果就是如果用户的程序中有地方用了 currentUser,将会打印非常大量的警告(可能一个请求会引发好几次警告)。

比如在我程序中 AV._config.disableCurrentUser = true 的情况下调用了一次 currentUser,应该只有一次警告,调用两次就有两次警告是比较合理的。如果出现多次,那是应该修正,但是目前程序看起来是所有不正确调用,只出现一次警告,就不太合理了。

@codecov-io
Copy link

codecov-io commented May 27, 2016

Current coverage is 63.82%

Merging #291 into master will decrease coverage by <.01%

  1. 2 files (not in diff) in dist/node were modified. more
    • Misses +5
    • Hits +4
@@             master       #291   diff @@
==========================================
  Files            27         27          
  Lines          2896       2905     +9   
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
+ Hits           1850       1854     +4   
- Misses         1046       1051     +5   
  Partials          0          0          

Powered by Codecov. Last updated by ee8b86e...8faae0a

@jysperm
Copy link
Contributor Author

jysperm commented May 27, 2016

我觉得既然是警告的话,只打印一次是合理的;或者就是把这个地方改为一个异常,这样才能迫使用户修改代码。实际上关于警告和异常我一直都在犹豫。

@wangxiao
Copy link
Contributor

讨论结论:每次都打印一条 warning(含文档链接),调用栈打印在 debug 里。

@wangxiao wangxiao merged commit 7d8b430 into leancloud:master May 30, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants