From 0fec4ea6b795c3bc67845d169086d2f0bd64b4e7 Mon Sep 17 00:00:00 2001 From: Lauren Tan Date: Wed, 23 Apr 2025 20:49:05 -0400 Subject: [PATCH] [forgive] Don't crash if we couldn't compile Compiler shouldn't crash Forgive if it can't compile (eg parse error due to being mid-typing). Co-authored-by: Jordan Brown --- .../packages/react-forgive/server/src/index.ts | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/compiler/packages/react-forgive/server/src/index.ts b/compiler/packages/react-forgive/server/src/index.ts index e4b75df194..edb6d63f02 100644 --- a/compiler/packages/react-forgive/server/src/index.ts +++ b/compiler/packages/react-forgive/server/src/index.ts @@ -134,11 +134,17 @@ documents.onDidChangeContent(async event => { resetState(); if (SUPPORTED_LANGUAGE_IDS.has(event.document.languageId)) { const text = event.document.getText(); - await compile({ - text, - file: event.document.uri, - options: compilerOptions, - }); + try { + await compile({ + text, + file: event.document.uri, + options: compilerOptions, + }); + } catch (err) { + if (err instanceof Error) { + connection.console.error(err.stack ?? ''); + } + } } });