diff --git a/src/serializableStateInvariantMiddleware.test.ts b/src/serializableStateInvariantMiddleware.test.ts index 5044f7dab8..9c3476f8df 100644 --- a/src/serializableStateInvariantMiddleware.test.ts +++ b/src/serializableStateInvariantMiddleware.test.ts @@ -385,4 +385,27 @@ describe('serializableStateInvariantMiddleware', () => { (See https://redux.js.org/faq/organizing-state#can-i-put-functions-promises-or-other-non-serializable-items-in-my-store-state)" `) }) + + it('should not check serializability for meta.args by default', () => { + const badValue = new Map() + + const reducer: Reducer = (state = 42, action) => { + return state + } + + const serializableStateInvariantMiddleware = createSerializableStateInvariantMiddleware() + + const store = configureStore({ + reducer: { + testSlice: reducer + }, + middleware: [serializableStateInvariantMiddleware] + }) + + store.dispatch({ type: 'testAction', meta: { args: { badValue } } }) + + const { log } = getLog() + expect(log).toBe('') + const q = 42 + }) }) diff --git a/src/serializableStateInvariantMiddleware.ts b/src/serializableStateInvariantMiddleware.ts index a702ec926f..978b0a7a26 100644 --- a/src/serializableStateInvariantMiddleware.ts +++ b/src/serializableStateInvariantMiddleware.ts @@ -35,7 +35,7 @@ export function findNonSerializableValue( path: ReadonlyArray = [], isSerializable: (value: unknown) => boolean = isPlain, getEntries?: (value: unknown) => [string, any][], - ignoredPaths: string[] = [] + ignoredPaths: string[] = ['meta.args'] ): NonSerializableValue | false { let foundNestedSerializable: NonSerializableValue | false