Skip to content

Commit 9276c2e

Browse files
committed
Clean up entry in finally block
1 parent 092863d commit 9276c2e

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

server/src/incrementalCompilation.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -746,11 +746,6 @@ async function compileContents(
746746
return;
747747
}
748748

749-
getLogger().log("Resetting compilation status.");
750-
// Reset compilation status as this compilation finished
751-
entry.compilation = null;
752-
entry.abortCompilation = null;
753-
754749
processAndPublishDiagnostics(
755750
entry,
756751
result,
@@ -765,11 +760,19 @@ async function compileContents(
765760
`Compilation of ${entry.file.sourceFileName} was aborted.`,
766761
);
767762
} else {
763+
getLogger().error(
764+
`Unexpected error during compilation of ${entry.file.sourceFileName}: ${error}`,
765+
);
768766
throw error;
769767
}
768+
} finally {
769+
// Only clean up if this is still the active compilation
770+
if (entry.compilation?.triggerToken === triggerToken) {
771+
getLogger().log("Cleaning up compilation status.");
772+
entry.compilation = null;
773+
entry.abortCompilation = null;
774+
}
770775
}
771-
} catch (e) {
772-
console.error(e);
773776
} finally {
774777
onCompilationFinished?.();
775778
}

0 commit comments

Comments
 (0)