From a2a33ca62d4651c11829e8d7d0504bbda57fa0f4 Mon Sep 17 00:00:00 2001 From: V Date: Tue, 30 May 2023 15:21:24 +0200 Subject: [PATCH] Fix occasional freezing on firefox (cache related) --- src/webpack/patchWebpack.ts | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/src/webpack/patchWebpack.ts b/src/webpack/patchWebpack.ts index f33ddc32f..f422372c1 100644 --- a/src/webpack/patchWebpack.ts +++ b/src/webpack/patchWebpack.ts @@ -28,21 +28,27 @@ let webpackChunk: any[]; const logger = new Logger("WebpackInterceptor", "#8caaee"); -Object.defineProperty(window, WEBPACK_CHUNK, { - get: () => webpackChunk, - set: v => { - if (v?.push !== Array.prototype.push) { - logger.info(`Patching ${WEBPACK_CHUNK}.push`); - _initWebpack(v); - patchPush(); - // @ts-ignore - delete window[WEBPACK_CHUNK]; - window[WEBPACK_CHUNK] = v; - } - webpackChunk = v; - }, - configurable: true -}); +if (window[WEBPACK_CHUNK]) { + logger.info(`Patching ${WEBPACK_CHUNK}.push (was already existant, likely from cache!)`); + _initWebpack(window[WEBPACK_CHUNK]); + patchPush(); +} else { + Object.defineProperty(window, WEBPACK_CHUNK, { + get: () => webpackChunk, + set: v => { + if (v?.push !== Array.prototype.push) { + logger.info(`Patching ${WEBPACK_CHUNK}.push`); + _initWebpack(v); + patchPush(); + // @ts-ignore + delete window[WEBPACK_CHUNK]; + window[WEBPACK_CHUNK] = v; + } + webpackChunk = v; + }, + configurable: true + }); +} function patchPush() { function handlePush(chunk: any) {