Skip to content

Commit

Permalink
Wex: Fix race condition with applying request_timeout value (#905)
Browse files Browse the repository at this point in the history
  • Loading branch information
psrok1 committed Feb 6, 2024
1 parent ee5cb12 commit e44c58a
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions mwdb/web/src/commons/config/provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,12 @@ export function ConfigProvider(props: Props) {
async function updateServerInfo() {
try {
const response = await api.getServerInfo();
const serverConfig = response.data;
// Update default axios timeout before marking config as ready
api.axios.defaults.timeout = serverConfig["request_timeout"];
setServerConfig({
type: configUpdate,
config: response.data,
config: serverConfig,
});
} catch (error) {
setServerConfig({
Expand Down Expand Up @@ -117,15 +120,6 @@ export function ConfigProvider(props: Props) {
if (auth.isAuthenticated) updateRemoteInfo();
}, [auth.isAuthenticated]);

useEffect(() => {
if (
serverConfig.config &&
Number.isInteger(serverConfig.config.request_timeout)
) {
api.axios.defaults.timeout = serverConfig.config["request_timeout"];
}
}, [serverConfig]);

useEffect(() => {
if (
serverConfig.config &&
Expand Down

0 comments on commit e44c58a

Please sign in to comment.