fix(ui/client): client issues
This commit is contained in:
parent
cff7ce6af4
commit
794b14c4d4
2 changed files with 9 additions and 4 deletions
|
@ -142,6 +142,7 @@ export class BaseClient {
|
|||
return new Promise((resolve: (ret: Response) => void) => {
|
||||
setTimeout(() => {
|
||||
if (!returned) {
|
||||
returned = true;
|
||||
src.cancel("request timeout");
|
||||
resolve(TimeoutResp);
|
||||
}
|
||||
|
@ -149,13 +150,17 @@ export class BaseClient {
|
|||
|
||||
axios({ ...config, cancelToken: src.token })
|
||||
.then((resp) => {
|
||||
if (!returned) {
|
||||
returned = true;
|
||||
resolve(resp);
|
||||
}
|
||||
})
|
||||
.catch((e) => {
|
||||
returned = true;
|
||||
const errMsg = e.toString();
|
||||
|
||||
if (errMsg.includes("ERR_EMPTY")) {
|
||||
// TODO: check if this is compatible with all browsers
|
||||
// this means connection is eliminated by server, it may be caused by timeout.
|
||||
resolve(EmptyBodyResp);
|
||||
} else if (e.response != null) {
|
||||
|
|
|
@ -40,7 +40,7 @@ export const resps = {
|
|||
role: "mock_role0",
|
||||
usedSpace: "128",
|
||||
quota: {
|
||||
spaceLimit: 1024,
|
||||
spaceLimit: "1024",
|
||||
uploadSpeedLimit: 1024,
|
||||
downloadSpeedLimit: 1024,
|
||||
},
|
||||
|
@ -52,7 +52,7 @@ export const resps = {
|
|||
role: "mock_role1",
|
||||
usedSpace: "256",
|
||||
quota: {
|
||||
spaceLimit: 1024,
|
||||
spaceLimit: "1024",
|
||||
uploadSpeedLimit: 1024,
|
||||
downloadSpeedLimit: 1024,
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue