Skip to content

Commit 1a575ef

Browse files
authored
Merge pull request github#14167 from asgerf/ts/tolerate-out-of-order-requests
JS: tolerate out of order requests in TypeScript extractor
2 parents e1ffc8d + ea384b3 commit 1a575ef

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,10 @@ function handleParseCommand(command: ParseCommand, checkPending = true) {
361361
let filename = command.filename;
362362
let expectedFilename = state.pendingFiles[state.pendingFileIndex];
363363
if (expectedFilename !== filename && checkPending) {
364-
throw new Error("File requested out of order. Expected '" + expectedFilename + "' but got '" + filename + "'");
364+
// File was requested out of order. This happens in rare cases because the Java process decided against extracting it,
365+
// for example because it was too large. Just recover and accept that some work was wasted.
366+
state.pendingResponse = null;
367+
state.pendingFileIndex = state.pendingFiles.indexOf(filename);
365368
}
366369
++state.pendingFileIndex;
367370
let response = state.pendingResponse || extractFile(command.filename);
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
category: fix
3+
---
4+
* Fixed an extractor crash that could occur in projects containing TypeScript files larger than 10 MB.

0 commit comments

Comments
 (0)