Skip to content

Commit

Permalink
Fix(Network): Fix Fetch stays in pending status when window is pr…
Browse files Browse the repository at this point in the history
…oxied. (issue #556)
  • Loading branch information
Maizify committed Sep 21, 2022
1 parent 61cc1f4 commit 2ea8a8a
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ English | [简体中文](./CHANGELOG_CN.md)
- `Fix(Log)` Fix `window.onerror` missing line breaks.
- `Fix(Log)` Fix unclickable `vc-cmd-clear-btn` on iOS Safari. (PR #564)
- `Fix(Log)` Fix a typo that misjudged circular reference objects. (issue #566)
- `Fix(Network)` Fix `Fetch` stays in pending status when `window` is proxied. (issue #556)
- `Fix(Storage)` Fix storage pannel sorting error when setting `storage.defaultStorages` option. (issue #560)
- `Fix(Core)` Fix plugin panel sorting error when setting `pluginOrder` option. (issue #559)
- `Fix(Core)` Fix intervention error caused by `preventDefault` in `Touch` events. (issue #546)
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- `Fix(Log)` 修复 `window.onerror` 丢失换行的问题。
- `Fix(Log)` 修复清除命令行按钮在 iOS Safari 中无法点击的问题。 (PR #564)
- `Fix(Log)` 修复一处误判循环引用对象的笔误。 (issue #566)
- `Fix(Network)` 修复因 `window` 对象被代理导致 `Fetch` 一直为 pending 状态的问题。 (issue #556)
- `Fix(Storage)` 修复因设置 `storage.defaultStorages` 导致 Storage 面板排序错误的问题。 (issue #560)
- `Fix(Core)` 修复因设置 `pluginOrder` 导致插件面板排序错误的问题。 (issue #559)
- `Fix(Core)` 修复因 `Touch` 事件中的 `preventDefault` 导致的 intervention 错误。 (issue #546)
Expand Down
4 changes: 2 additions & 2 deletions src/network/fetch.proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,13 @@ export class FetchProxyHandler<T extends typeof fetch> implements ProxyHandler<T
this.onUpdateCallback = onUpdateCallback;
}

public apply(target: T, thisArg: T, argsList) {
public apply(target: T, thisArg: typeof window, argsList) {
const input: RequestInfo = argsList[0];
const init: RequestInit = argsList[1];
const item = new VConsoleNetworkRequestItem();
this.beforeFetch(item, input, init);

return (<ReturnType<T>>target.apply(thisArg, argsList)).then(this.afterFetch(item)).catch((e) => {
return (<ReturnType<T>>target.apply(window, argsList)).then(this.afterFetch(item)).catch((e) => {
// mock finally
item.endTime = Date.now();
item.costTime = item.endTime - (item.startTime || item.endTime);
Expand Down

0 comments on commit 2ea8a8a

Please sign in to comment.