leancloud / leanengine-node-sdk

LeanEngine Node.js SDK

Home Page:https://leancloud.cn

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

高并发跳号问题

sqlwwx opened this issue · comments

leanengine-node-sdk/lib/av-extra.js

AV.User._saveCurrentUser = function(user) {
  debug('_saveCurrentUser %s', user.get('username'));
  if (process.domain) {
    if (process.domain._currentUser === user) {
      return;
    }
    if (process.domain._currentUser) {
      AV.User.logOut();
    }
    if (user) {
      user._isCurrentUser = true;
    }
    process.domain._currentUser = user;
    return;
  }
  throw new Error('请添加 AV.Cloud.CookieSession 中间件以支持 AV.User 的操作。');
};

先设置了_isCurrentUser在高并发情况下会导致串号

AV.User._saveCurrentUser = function(user) {
  debug('_saveCurrentUser %s', user.get('username'));
  if (process.domain) {
    if (process.domain._currentUser === user) {
      return;
    }
    if (process.domain._currentUser) {
      AV.User.logOut();
    }
    if (user) {
      process.domain._currentUser = user;
      user._isCurrentUser = true;
    }  
    return;
  }
  throw new Error('请添加 AV.Cloud.CookieSession 中间件以支持 AV.User 的操作。');
};
commented

你好,我没明白你要表达什么意思,两端代码看起来是将 process.domain._currentUser = user; 语句移动到 if 判断里面了。

能说明下串号的原因吗?

在 2015年10月26日,上午9:55,wchen <notifications@github.commailto:notifications@github.com> 写道:

你好,我没明白你要表达什么意思,两端代码看起来是将 process.domain._currentUser = user; 语句移动到 if 判断里面了。

能说明下串号的原因吗?


Reply to this email directly or view it on GitHubhttps://github.com//issues/36#issuecomment-151000503.

周末的时候是这么改就不会跳号了,现在把代码改也回去重现不出来了。。。。

commented

下面这段代码是针对串号的测试,你可以尝试修改下测试来重现下问题:

https://github.com/leancloud/leanengine-node-sdk/blob/master/test/function_test.js#L578-L621

在 2015年10月26日,上午11:21,wchen <notifications@github.commailto:notifications@github.com> 写道:

下面这段代码是针对串号的测试,你可以尝试修改下测试来重现下问题:

https://github.com/leancloud/leanengine-node-sdk/blob/master/test/function_test.js#L578-L621


Reply to this email directly or view it on GitHubhttps://github.com//issues/36#issuecomment-151012990.

无语,又串号。

commented

麻烦提供一个能重现串号的测试给我,我确认下。

在 2015年10月26日,下午1:24,wchen <notifications@github.commailto:notifications@github.com> 写道:

麻烦提供一个能重现串号的测试给我,我确认下。


Reply to this email directly or view it on GitHubhttps://github.com//issues/36#issuecomment-151027780.

这是我们的app http://www.pgyer.com/YjmAndroid
两个账号登陆之后在资产页面下来刷新就会串号。
你还需要我提供哪些信息

在 2015年10月26日,下午1:24,wchen <notifications@github.commailto:notifications@github.com> 写道:

麻烦提供一个能重现串号的测试给我,我确认下。


Reply to this email directly or view it on GitHubhttps://github.com//issues/36#issuecomment-151027780.

方便给个联系方式?

commented

很抱歉,我们按照你描述的方式进行测试,仍然没有发现问题。

麻烦提供下你的重现方式。

我们现在也无法重现,AV.Cloud.CookieSession 的配置项 overwrite被强制设为true,改成false,避免重写客户端cookie,会不会产生其他问题。
leanengine/lib/avosExpressCookieSession/index.js 25

     if (!opts.overwrite) {
        opts.overwrite = true;
      }
commented

抱歉,因为实在没办法重现,这个 issue 先关闭。