@samitouri / QOS-React / commits / b75af04670

[forgive] Don't crash if we couldn't compile (#33001)

Compiler shouldn't crash Forgive if it can't compile (eg parse error due to being mid-typing). Co-authored-by: Jordan Brown <jmbrown@meta.com> --- [//]: # (BEGIN SAPLING FOOTER) Stack created with [Sapling](https://sapling-scm.com). Best reviewed with [ReviewStack](https://reviewstack.dev/facebook/react/pull/33001). * #33002 * __->__ #33001 * #33000 --------- Co-authored-by: Jordan Brown <jmbrown@meta.com>

lauren committed Apr 23, 2025 at 21:32 UTC b75af0467099b7fd0e668b500adb0888b7b21d10
1 file changed +11 -5
compiler/packages/react-forgive/server/src/index.ts
+11 -5
@@ -134,11 +134,17 @@ documents.onDidChangeContent(async event => {
134 resetState();
135 if (SUPPORTED_LANGUAGE_IDS.has(event.document.languageId)) {
136 const text = event.document.getText();
137 - await compile({
138 - text,
139 - file: event.document.uri,
140 - options: compilerOptions,
141 - });
137 + try {
138 + await compile({
139 + text,
140 + file: event.document.uri,
141 + options: compilerOptions,
142 + });
143 + } catch (err) {
144 + if (err instanceof Error) {
145 + connection.console.error(err.stack ?? '');
146 + }
147 + }
148 }
149 });
150