From 4c4d718bd1663bbbc96bd6fea5989a0631e49423 Mon Sep 17 00:00:00 2001 From: Lauren Tan Date: Wed, 23 Apr 2025 16:27:30 -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 ?? ''); + } + } } });