diff --git a/packages/playground/src/sidebar/runtime.ts b/packages/playground/src/sidebar/runtime.ts
index 75b454242d42..8eddf27aac17 100644
--- a/packages/playground/src/sidebar/runtime.ts
+++ b/packages/playground/src/sidebar/runtime.ts
@@ -234,18 +234,23 @@ function rewireLoggingToElement(
}
function produceOutput(args: any[]) {
- let result: string = args.reduce((output: any, arg: any, index) => {
- const textRep = objectToText(arg)
- const showComma = index !== args.length - 1
- const comma = showComma ? ", " : ""
- return output + textRep + comma + " "
- }, "")
-
- Object.keys(replacers).forEach(k => {
- result = result.replace(new RegExp((replacers as any)[k], "g"), k)
- })
-
- return result
+ try {
+ let result: string = args.reduce((output: any, arg: any, index) => {
+ const textRep = objectToText(arg)
+ const showComma = index !== args.length - 1
+ const comma = showComma ? ", " : ""
+ return output + textRep + comma + " "
+ }, "")
+
+ Object.keys(replacers).forEach(k => {
+ result = result.replace(new RegExp((replacers as any)[k], "g"), k)
+ })
+
+ return result
+ } catch (error) {
+ console.warn(i("play_run_log_fail"), error)
+ return i("play_run_log_fail")
+ }
}
}
diff --git a/packages/typescriptlang-org/src/copy/en/playground.ts b/packages/typescriptlang-org/src/copy/en/playground.ts
index 6936d5ea6cf7..aefa80fbb3c9 100644
--- a/packages/typescriptlang-org/src/copy/en/playground.ts
+++ b/packages/typescriptlang-org/src/copy/en/playground.ts
@@ -55,6 +55,7 @@ export const playCopy = {
play_run_js: "Executed JavaScript",
play_run_ts: "Executed transpiled TypeScript",
play_run_js_fail: "Executed JavaScript Failed:",
+ play_run_log_fail: "Failed to serialize log",
play_default_code_sample: `// Welcome to the TypeScript Playground, this is a website
// which gives you a chance to write, share and learn TypeScript.