fix(gui): set a reasonable timeout on the initial params fetch
This commit is contained in:
parent
b18567ca43
commit
50fe17bce1
|
@ -1,6 +1,7 @@
|
||||||
import { Alert, AlertTitle, Typography } from '@mui/material';
|
import { Alert, AlertTitle, Typography } from '@mui/material';
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import { PARAM_VERSION } from '../../config';
|
|
||||||
|
import { PARAM_VERSION } from '../../config.js';
|
||||||
|
|
||||||
export interface ParamsVersionErrorProps {
|
export interface ParamsVersionErrorProps {
|
||||||
root: string;
|
root: string;
|
||||||
|
@ -10,7 +11,7 @@ export interface ParamsVersionErrorProps {
|
||||||
export function ParamsVersionError(props: ParamsVersionErrorProps) {
|
export function ParamsVersionError(props: ParamsVersionErrorProps) {
|
||||||
return <Alert severity='error'>
|
return <Alert severity='error'>
|
||||||
<AlertTitle>
|
<AlertTitle>
|
||||||
Parameter Version Error
|
Parameter version error
|
||||||
</AlertTitle>
|
</AlertTitle>
|
||||||
<Typography>
|
<Typography>
|
||||||
The server returned parameters that are too old for the client to load.
|
The server returned parameters that are too old for the client to load.
|
||||||
|
|
|
@ -19,7 +19,7 @@ function getErrorMessage(error: unknown): string {
|
||||||
export function ServerParamsError(props: ServerParamsErrorProps) {
|
export function ServerParamsError(props: ServerParamsErrorProps) {
|
||||||
return <Alert severity='error'>
|
return <Alert severity='error'>
|
||||||
<AlertTitle>
|
<AlertTitle>
|
||||||
Server Error
|
Error fetching server parameters
|
||||||
</AlertTitle>
|
</AlertTitle>
|
||||||
<Typography>
|
<Typography>
|
||||||
Could not fetch parameters from the ONNX web API server at <code>{props.root}</code>.
|
Could not fetch parameters from the ONNX web API server at <code>{props.root}</code>.
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
/* eslint-disable no-console */
|
/* eslint-disable no-console */
|
||||||
import { mustDefault, mustExist } from '@apextoaster/js-utils';
|
import { mustDefault, mustExist, timeout } from '@apextoaster/js-utils';
|
||||||
import { merge } from 'lodash';
|
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import ReactDOM from 'react-dom/client';
|
import ReactDOM from 'react-dom/client';
|
||||||
import { QueryClient, QueryClientProvider } from 'react-query';
|
import { QueryClient, QueryClientProvider } from 'react-query';
|
||||||
|
@ -16,6 +15,8 @@ import { OnnxWeb } from './components/OnnxWeb.js';
|
||||||
import { getApiRoot, loadConfig, mergeConfig, PARAM_VERSION } from './config.js';
|
import { getApiRoot, loadConfig, mergeConfig, PARAM_VERSION } from './config.js';
|
||||||
import { ClientContext, ConfigContext, createStateSlices, OnnxState, StateContext } from './state.js';
|
import { ClientContext, ConfigContext, createStateSlices, OnnxState, StateContext } from './state.js';
|
||||||
|
|
||||||
|
export const INITIAL_LOAD_TIMEOUT = 5_000;
|
||||||
|
|
||||||
export async function main() {
|
export async function main() {
|
||||||
// load config from GUI server
|
// load config from GUI server
|
||||||
const config = await loadConfig();
|
const config = await loadConfig();
|
||||||
|
@ -30,7 +31,7 @@ export async function main() {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// load full params from the API server and merge with the initial client config
|
// load full params from the API server and merge with the initial client config
|
||||||
const params = await client.params();
|
const params = await timeout(INITIAL_LOAD_TIMEOUT, client.params());
|
||||||
const version = mustDefault(params.version, '0.0.0');
|
const version = mustDefault(params.version, '0.0.0');
|
||||||
if (satisfies(version, PARAM_VERSION)) {
|
if (satisfies(version, PARAM_VERSION)) {
|
||||||
const completeConfig = mergeConfig(config, params);
|
const completeConfig = mergeConfig(config, params);
|
||||||
|
|
Loading…
Reference in New Issue