From 32ade5b3e369662be8dbc9f392ae7d1c7d21e523 Mon Sep 17 00:00:00 2001 From: Jeongho Nam Date: Wed, 7 Aug 2024 13:48:13 +0900 Subject: [PATCH 1/2] Playground console movie to handle async function. --- website/src/pages/Playground.tsx | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/website/src/pages/Playground.tsx b/website/src/pages/Playground.tsx index 94193394d3..7cfb15b5a0 100644 --- a/website/src/pages/Playground.tsx +++ b/website/src/pages/Playground.tsx @@ -104,35 +104,41 @@ const Playground = () => { const execute = async () => { const service = await createCompilerService.get(); - const res: ICompilerService.IOutput = await service.bundle(source ?? ""); - if (res.success === false) + const compiled: ICompilerService.IOutput = await service.bundle( + source ?? "", + ); + if (compiled.success === false) return setConsoleBox({ messages: [ { type: "error", - value: res.error, + value: compiled.error, }, ], }); - const func: Function = new Function("console", res.content); + const func: Function = new Function("console", compiled.content); const messages: ConsoleViewer.IMessage[] = []; func({ error: (...args: any[]) => { console.error(...args); args.forEach((value) => messages.push({ type: "error", value })); + setConsoleBox({ messages }); }, info: (...args: any[]) => { console.info(...args); args.forEach((value) => messages.push({ type: "info", value })); + setConsoleBox({ messages }); }, log: (...args: any[]) => { console.log(...args); args.forEach((value) => messages.push({ type: "log", value })); + setConsoleBox({ messages }); }, warn: (...args: any[]) => { console.warn(...args); args.forEach((value) => messages.push({ type: "warn", value })); + setConsoleBox({ messages }); }, }); setConsoleBox({ messages }); From b5cfcce55de9d6fce86638ea2604d260a5c28963 Mon Sep 17 00:00:00 2001 From: Jeongho Nam Date: Wed, 7 Aug 2024 13:49:51 +0900 Subject: [PATCH 2/2] Remove vulnerable setState function call. --- website/src/pages/Playground.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/website/src/pages/Playground.tsx b/website/src/pages/Playground.tsx index 7cfb15b5a0..e543e1daad 100644 --- a/website/src/pages/Playground.tsx +++ b/website/src/pages/Playground.tsx @@ -141,7 +141,6 @@ const Playground = () => { setConsoleBox({ messages }); }, }); - setConsoleBox({ messages }); }; return (