Skip to content

Commit 6b091f0

Browse files
committed
Warning when serialized object has more than 16 MB
Related to #455, #476, #558, #543, #566.
1 parent 13891d7 commit 6b091f0

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/app/api/index.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,19 @@ function tryCatchStringify(obj) {
2727
}
2828
}
2929

30+
let stringifyWarned;
3031
function stringify(obj, serialize) {
31-
if (typeof serialize === 'undefined') {
32-
return tryCatchStringify(obj);
32+
const str = typeof serialize === 'undefined' ? tryCatchStringify(obj) :
33+
jsan.stringify(obj, serialize.replacer, null, serialize.options);
34+
35+
if (!stringifyWarned && str.length > 16 * 1024 * 1024) { // 16 MB
36+
/* eslint-disable no-console */
37+
console.warn('Application state or actions payloads are too large making Redux DevTools serialization slow and consuming a lot of memory. See https://git.io/fpcP5 on how to configure it.');
38+
/* eslint-enable no-console */
39+
stringifyWarned = true;
3340
}
34-
return jsan.stringify(obj, serialize.replacer, null, serialize.options);
41+
42+
return str;
3543
}
3644

3745
export function getSeralizeParameter(config, param) {

0 commit comments

Comments
 (0)