Skip to content

Commit fe43a11

Browse files
author
Ives van Hoorne
committed
Don't send caches which are too big to the client
1 parent 7c21aca commit fe43a11

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

packages/app/src/sandbox/eval/cache.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const debug = _debug('cs:compiler:cache');
99

1010
const host = process.env.CODESANDBOX_HOST;
1111

12+
const MAX_CACHE_SIZE = 1024 * 1024 * 7;
1213
let APICacheUsed = false;
1314

1415
try {
@@ -71,6 +72,10 @@ export async function saveCache(
7172
if (shouldSaveOnlineCache(firstRun, changes) && SCRIPT_VERSION) {
7273
const stringifiedManagerState = JSON.stringify(managerState);
7374

75+
if (stringifiedManagerState.length > MAX_CACHE_SIZE) {
76+
return Promise.resolve(false);
77+
}
78+
7479
debug(
7580
'Saving cache of ' +
7681
(stringifiedManagerState.length / 1024).toFixed(2) +

0 commit comments

Comments
 (0)