From 85b9daedb830920d6aaf99a50bd06bf8b5ee011b Mon Sep 17 00:00:00 2001 From: Oliver Eyton-Williams Date: Thu, 23 Dec 2021 14:34:26 +0000 Subject: [PATCH] fix(client): handle challenge resets with hidden preview (#44570) --- client/src/templates/Challenges/utils/frame.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/client/src/templates/Challenges/utils/frame.js b/client/src/templates/Challenges/utils/frame.js index 9d612dea0f..def4a19df4 100644 --- a/client/src/templates/Challenges/utils/frame.js +++ b/client/src/templates/Challenges/utils/frame.js @@ -91,7 +91,8 @@ const mountFrame = }; const buildProxyConsole = proxyLogger => ctx => { - if (proxyLogger) { + // window does not exist if the preview is hidden, so we have to check. + if (proxyLogger && ctx?.window) { const oldLog = ctx.window.console.log.bind(ctx.window.console); ctx.window.console.log = function proxyConsole(...args) { proxyLogger(args.map(arg => format(arg)).join(' '));