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

批量上报参数似乎有问题 #38

Open
white-shiro-bai opened this issue Apr 2, 2024 · 0 comments
Open

批量上报参数似乎有问题 #38

white-shiro-bai opened this issue Apr 2, 2024 · 0 comments

Comments

@white-shiro-bai
Copy link

white-shiro-bai commented Apr 2, 2024

代码段 sa.para里给定了上报超时的预设值

datasend_timeout: 3000,

如果开启了批量上报开关(目前是默认开启了)
会额外执行这段代码,调高上报超时的预设值,这是符合逻辑的。但是这里似乎有一个问题:

if (para && para.datasend_timeout);  //因为这里永远不会是false
  else if (sa.para.batch_send) {
    sa.para.datasend_timeout = 10000;  // 所以这里设置的不会生效
  }

他的原理可能是,

if (sa.para.batch_send === true) {
    sa.para.batch_send = _.extend({}, batch_send_default);
  } else if (_.isObject(sa.para.batch_send)) {
    sa.para.batch_send = _.extend({}, batch_send_default, sa.para.batch_send);
  }`

`function extend(obj) {
  each(slice.call(arguments, 1), function(source) {
    for (var prop in source) {
      if (source[prop] !== void 0) {
        obj[prop] = source[prop];
      }
    }
  });
  return obj;
}
function extend2Lev(obj) {
  each(slice.call(arguments, 1), function(source) {
    for (var prop in source) {
      if (source[prop] !== void 0 && source[prop] !== null) {
        if (isObject(source[prop]) && isObject(obj[prop])) {
          extend(obj[prop], source[prop]);
        } else {
          obj[prop] = source[prop];
        }
      }
    }
  });
  return obj;
}

即先用预设的sa.para作为基础,再判断用户给的初始化值是否合法,合法就更新。这导致datasend_timeout这个值,是永远都有值的,根本不会因为开启了批量发送,就走到下面的方法上,去调高超时时间。
在测试环节中可以复现此现象,即手工指定超时时间为10,批量发送100%复现。不会因为有10000的批量发送修改,就改为10000。

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

No branches or pull requests

1 participant