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

feat: network soft timeout alert banner #2493

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion resources/i18n/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@
"UNAUTHORIZEDACCESS": "허가되지 않은 접근입니다.",
"AdminOnlyPage": "접근하려는 페이지는 관리자 권한이 필요합니다.<br /> 아래 버튼을 클릭하면 요약 페이지로 돌아갑니다.",
"CleanUpLoginSession": "로그인 된 세션을 종료합니다...",
"CleanUpNow": "종료합니다..."
"CleanUpNow": "종료합니다...",
"NetworkSoftTimeout": "서버와의 연결이 원할하지 않습니다."
},
"summary": {
"StartMenu": "시작",
Expand Down
14 changes: 13 additions & 1 deletion src/lib/backend.ai-client-esm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,12 @@ class Client {
public abortController: any;
public abortSignal: any;
public requestTimeout: number;
public requestSoftTimeout: number;
static ERR_REQUEST: any;
static ERR_RESPONSE: any;
static ERR_ABORT: any;
static ERR_TIMEOUT: any;
static ERR_SOFT_TIMEOUT: any;
static ERR_SERVER: any;
static ERR_UNKNOWN: any;

Expand Down Expand Up @@ -267,6 +269,7 @@ class Client {
this.abortController = new AbortController();
this.abortSignal = this.abortController.signal;
this.requestTimeout = 15000;
this.requestSoftTimeout = 10000;
if (localStorage.getItem('backendaiwebui.sessionid')) {
this._loginSessionId = localStorage.getItem('backendaiwebui.sessionid');
} else {
Expand Down Expand Up @@ -313,7 +316,7 @@ class Client {
let errorTitle = '';
let errorMsg;
let errorDesc = '';
let resp, body, requestTimer;
let resp, body, requestTimer, requestTimerForSoftTimeout;
try {
if (rqst.method === 'GET') {
rqst.body = undefined;
Expand All @@ -336,11 +339,20 @@ class Client {
},
timeout === 0 ? this.requestTimeout : timeout,
);
requestTimerForSoftTimeout = setTimeout(
() => {
document?.dispatchEvent(new CustomEvent('backendai.client.softtimeout'));
}
);
}
resp = await fetch(rqst.uri, rqst);
if (typeof requestTimer !== 'undefined') {
clearTimeout(requestTimer);
}
if (typeof requestTimerForSoftTimeout !== 'undefined') {
clearTimeout(requestTimerForSoftTimeout);
}

let loginSessionId = resp.headers.get('X-BackendAI-SessionID'); // Login session ID handler
if (loginSessionId) {
this._loginSessionId = loginSessionId;
Expand Down
Loading