Skip to content

Commit

Permalink
Fix(Network): Fix responseSize error when readyState === 3.
Browse files Browse the repository at this point in the history
  • Loading branch information
Maizify committed Mar 24, 2022
1 parent 6693584 commit f7b913a
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
English | [简体中文](./CHANGELOG_CN.md)

## 3.14.1 (2022-03-24)

- `Fix(Network)` Fix `responseSize` error when `readyState === 3`.


## 3.14.0 (2022-03-23)

- `Feat(Core)` Add new option `pluginOrder` to adjust the order of built-in and custom plugins, see [Public Properties & Methods](./doc/public_properties_methods.md).
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG_CN.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
[English](./CHANGELOG.md) | 简体中文

## 3.14.1 (2022-03-24)

- `Fix(Network)` 修复当 `readyState === 3` 时的 `responseSize` 错误。


## 3.14.0 (2022-03-23)

- `Feat(Core)` 新增配置项 `pluginOrder` 来调整插件面板的排序,见 [公共属性及方法](./doc/public_properties_methods_CN.md)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vconsole",
"version": "3.14.0",
"version": "3.14.1",
"description": "A lightweight, extendable front-end developer tool for mobile web page.",
"homepage": "https://github.com/Tencent/vConsole",
"files": [
Expand Down
8 changes: 5 additions & 3 deletions src/network/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,10 @@ export const updateItemByReadyState = (item: VConsoleNetworkRequestItem, XMLReq:
case 3: // LOADING
item.status = XMLReq.status;
item.statusText = 'Loading';
item.responseSize = XMLReq.response.length;
item.responseSizeText = tool.getBytesText(item.responseSize);
if (typeof XMLReq.response === 'object' && XMLReq.response.length) {
item.responseSize = XMLReq.response.length;
item.responseSizeText = tool.getBytesText(item.responseSize);
}
break;

case 4: // DONE
Expand All @@ -117,7 +119,7 @@ export const updateItemByReadyState = (item: VConsoleNetworkRequestItem, XMLReq:
item.endTime = Date.now(),
item.costTime = item.endTime - (item.startTime || item.endTime);
item.response = XMLReq.response;
if (XMLReq.response.length) {
if (typeof XMLReq.response === 'object' && XMLReq.response.length) {
item.responseSize = XMLReq.response.length;
item.responseSizeText = tool.getBytesText(item.responseSize);
}
Expand Down

0 comments on commit f7b913a

Please sign in to comment.