Skip to content

Commit 549d4e9

Browse files
committed
JS: Do not restart in the middle of a message
1 parent e1657b2 commit 549d4e9

File tree

1 file changed

+3
-1
lines changed
  • javascript/extractor/lib/typescript/src

1 file changed

+3
-1
lines changed

javascript/extractor/lib/typescript/src/main.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ function extractFile(filename: string): string {
163163
function prepareNextFile() {
164164
if (state.pendingResponse != null) return;
165165
if (state.pendingFileIndex < state.pendingFiles.length) {
166+
checkMemoryUsage();
166167
let nextFilename = state.pendingFiles[state.pendingFileIndex];
167168
state.pendingResponse = extractFile(nextFilename);
168169
}
@@ -538,6 +539,8 @@ let isAboveReloadThreshold = false;
538539

539540
/**
540541
* If memory usage has moved above a the threshold, reboot the TypeScript compiler instance.
542+
*
543+
* Make sure to call this only when stdout has been flushed.
541544
*/
542545
function checkMemoryUsage() {
543546
let bytesUsed = process.memoryUsage().heapUsed;
@@ -560,7 +563,6 @@ function runReadLineInterface() {
560563
switch (req.command) {
561564
case "parse":
562565
handleParseCommand(req);
563-
checkMemoryUsage();
564566
break;
565567
case "open-project":
566568
handleOpenProjectCommand(req);

0 commit comments

Comments
 (0)