Skip to content

修复 sdk 最近的一些 issue #400

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

Merged
merged 13 commits into from
Feb 18, 2019
Merged

修复 sdk 最近的一些 issue #400

merged 13 commits into from
Feb 18, 2019

Conversation

winddies
Copy link
Contributor

@winddies winddies commented Oct 16, 2018

fix #411 fix #372 fix #386 fix #362
这次更改主要解决以下问题:

  1. 某些浏览器环境下,xhr 的 progress 事件无法被触发,之前以为只是在低版本浏览器中出现,后来发现,在 ios12 仍然有该现象,之前打算对浏览器版本进行判断,后来发现并不准确,目前采取比较中和的方式,在每次分片完成后都更新下进度
  2. 静态日志的请求发送在打开之前,会报错
  3. 优化断点记录,在每次分片请求完成后都记录一下,避免出现浏览器退出或者刷新浏览器导致断点没有记录的问题

@winddies winddies changed the title 修复浏览器兼容性问题 修复 sdk 最近的一些 issue Feb 18, 2019
@nighca
Copy link
Contributor

nighca commented Feb 18, 2019

在 PR 描述里写 fix #xxx(### 是 issue 号)的话,它会自动关联对应的 issue 的,这个 PR merge 了也会自动 close 对应的 issue

Copy link
Collaborator

@yinxulai yinxulai left a comment

Choose a reason for hiding this comment

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

完美

src/upload.js Outdated
@@ -273,8 +276,15 @@ export class UploadManager {
}

finishDirectProgress(){
Copy link
Collaborator

Choose a reason for hiding this comment

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

空格 哈哈哈

@@ -273,8 +276,15 @@ export class UploadManager {
}

finishDirectProgress(){
// 在某些浏览器环境下,xhr 的 progress 事件无法被触发,progress 为 null, 这里 fake 下
if (!this.progress) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

整体流程上看 progress 为 null 的情况确认只需要处理这一处吗?
记得之前出 bug 好像有不止一个地方会因为 progress 出 null 的问题的…

Copy link
Contributor Author

Choose a reason for hiding this comment

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

有两处啊,毕竟上传方式有两种

@@ -231,12 +230,16 @@ export class UploadManager {
onProgress,
onCreate
}).then(response => {
// 在某些浏览器环境下,xhr 的 progress 事件无法被触发,progress 为 null,这里在每次分片上传完成后都手动更新下 progress
onProgress({ loaded: chunk.size });
Copy link
Collaborator

Choose a reason for hiding this comment

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

确认一下 progress 多触发一两次没问题吗?
另外触发顺序检查了吗?(确保 progress 一定是增的或者说不减的,并且一定在 complete 前触发)

"es3ify-loader": "^0.2.0",
"open-browser-webpack-plugin": "0.0.5",
"qiniu-js": "^2.5.4",
Copy link
Collaborator

Choose a reason for hiding this comment

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

只需要更新一个 demo 的依赖?

Copy link
Contributor Author

@winddies winddies Feb 18, 2019

Choose a reason for hiding this comment

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

是的,只有这个是单独有自己的node_modules

xhr.open("POST", "https://uplog.qbox.me/log/3");
xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhr.setRequestHeader("Authorization", "UpToken " + token);
xhr.onreadystatechange = function () {
if (xhr.readyState === 4) {
if (xhr.status !== 200) {
count++;
count <= 3 ? xhr.send(logString) : "";
}
count <= 3 ? self.send(logString, token) : "";
Copy link
Collaborator

Choose a reason for hiding this comment

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

3 这个 magic number 哪来的?
是配置项里的 retryCount 吗?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

不是, 这里它自己的重试,不过这里的确有点问题

Copy link
Collaborator

@lzfee0227 lzfee0227 left a comment

Choose a reason for hiding this comment

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

👌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants