From 543e6ef717275afb0060f26cb9cc03f6e4dc67e0 Mon Sep 17 00:00:00 2001 From: Kamil Gabryjelski Date: Mon, 12 Jun 2023 17:46:00 +0200 Subject: [PATCH] chore: Disable redux errors --- superset-frontend/src/views/store.ts | 30 +++++++++++++++++----------- superset-frontend/webpack.config.js | 2 ++ 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/superset-frontend/src/views/store.ts b/superset-frontend/src/views/store.ts index 78d5a99714f02..193386a5ffba3 100644 --- a/superset-frontend/src/views/store.ts +++ b/superset-frontend/src/views/store.ts @@ -17,6 +17,7 @@ * under the License. */ import { configureStore, ConfigureStoreOptions, Store } from '@reduxjs/toolkit'; +import thunk from 'redux-thunk'; import { api } from 'src/hooks/apiResources/queryApi'; import messageToastReducer from 'src/components/MessageToasts/reducers'; import charts from 'src/components/Chart/chartReducer'; @@ -75,6 +76,22 @@ const userReducer = ( return user; }; +const getMiddleware: ConfigureStoreOptions['middleware'] = + getDefaultMiddleware => + process.env.REDUX_DEFAULT_MIDDLEWARE + ? getDefaultMiddleware({ + immutableCheck: { + warnAfter: 200, + }, + serializableCheck: { + // Ignores AbortController instances + ignoredActionPaths: [/queryController/g], + ignoredPaths: [/queryController/g], + warnAfter: 200, + }, + }).concat(logger, api.middleware) + : [thunk, logger, api.middleware]; + // TODO: This reducer is a combination of the Dashboard and Explore reducers. // The correct way of handling this is to unify the actions and reducers from both // modules in shared files. This involves a big refactor to unify the parameter types @@ -137,18 +154,7 @@ export function setupStore({ [api.reducerPath]: api.reducer, ...rootReducers, }, - middleware: getDefaultMiddleware => - getDefaultMiddleware({ - immutableCheck: { - warnAfter: 200, - }, - serializableCheck: { - // Ignores AbortController instances - ignoredActionPaths: [/queryController/g], - ignoredPaths: [/queryController/g], - warnAfter: 200, - }, - }).concat(logger, api.middleware), + middleware: getMiddleware, devTools: process.env.WEBPACK_MODE === 'development' && !disableDebugger, ...overrides, }); diff --git a/superset-frontend/webpack.config.js b/superset-frontend/webpack.config.js index cf61a352ed63a..f728ce23dfb2d 100644 --- a/superset-frontend/webpack.config.js +++ b/superset-frontend/webpack.config.js @@ -116,6 +116,8 @@ const plugins = [ // expose mode variable to other modules new webpack.DefinePlugin({ 'process.env.WEBPACK_MODE': JSON.stringify(mode), + 'process.env.REDUX_DEFAULT_MIDDLEWARE': + process.env.REDUX_DEFAULT_MIDDLEWARE, }), new CopyPlugin({