Skip to content

Commit b75af04

Browse files
potetojbrown215
andauthored
[forgive] Don't crash if we couldn't compile (facebook#33001)
Compiler shouldn't crash Forgive if it can't compile (eg parse error due to being mid-typing). Co-authored-by: Jordan Brown <[email protected]> --- [//]: # (BEGIN SAPLING FOOTER) Stack created with [Sapling](https://sapling-scm.com). Best reviewed with [ReviewStack](https://reviewstack.dev/facebook/react/pull/33001). * facebook#33002 * __->__ facebook#33001 * facebook#33000 --------- Co-authored-by: Jordan Brown <[email protected]>
1 parent f765082 commit b75af04

File tree

1 file changed

+11
-5
lines changed
  • compiler/packages/react-forgive/server/src

1 file changed

+11
-5
lines changed

compiler/packages/react-forgive/server/src/index.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,17 @@ documents.onDidChangeContent(async event => {
134134
resetState();
135135
if (SUPPORTED_LANGUAGE_IDS.has(event.document.languageId)) {
136136
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+
}
142148
}
143149
});
144150

0 commit comments

Comments
 (0)