Skip to content

Commit 2952ced

Browse files
committed
wasm: tolerate qljs_vscode_destroy_document crashes
1 parent 5ea7a9c commit 2952ced

File tree

2 files changed

+17
-16
lines changed

2 files changed

+17
-16
lines changed

wasm/quick-lint-js.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,15 @@ class DocumentLinter {
108108
}
109109
}
110110
if (this._parser !== null) {
111-
this._parser.dispose();
111+
try {
112+
this._parser.dispose();
113+
} catch (e) {
114+
if (e instanceof ProcessCrashed) {
115+
// Ignore.
116+
} else {
117+
throw e;
118+
}
119+
}
112120
}
113121
break;
114122
}

wasm/test-document.js

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -209,11 +209,7 @@ describe("DocumentLinter", () => {
209209
);
210210
// TODO(strager): Figure out why qljs_vscode_create_document failures
211211
// cause this test to fail.
212-
// TODO(strager): Fix problems when qljs_vscode_destroy_document fails.
213-
if (
214-
functionName !== "qljs_vscode_create_document" &&
215-
functionName != "qljs_vscode_destroy_document"
216-
) {
212+
if (functionName !== "qljs_vscode_create_document") {
217213
let shouldCrash = rng.nextCoinFlip();
218214
coinFlips.push(shouldCrash);
219215
if (shouldCrash) {
@@ -290,7 +286,7 @@ describe("DocumentLinter", () => {
290286
}
291287
}
292288
}
293-
});
289+
}, /*timeout=*/ 60_000);
294290

295291
it("concurrent edits are applied in order of calls, with exhaustive fault injection", async () => {
296292
let coinFlips;
@@ -301,14 +297,11 @@ describe("DocumentLinter", () => {
301297
!crashedProcesses.has(process),
302298
"Should not use previously-crashed process"
303299
);
304-
// TODO(strager): Fix problems when qljs_vscode_destroy_document fails.
305-
if (functionName != "qljs_vscode_destroy_document") {
306-
let shouldCrash = rng.nextCoinFlip();
307-
coinFlips.push(shouldCrash);
308-
if (shouldCrash) {
309-
crashedProcesses.add(process);
310-
throw new qljs.ProcessCrashed("(injected fault)");
311-
}
300+
let shouldCrash = rng.nextCoinFlip();
301+
coinFlips.push(shouldCrash);
302+
if (shouldCrash) {
303+
crashedProcesses.add(process);
304+
throw new qljs.ProcessCrashed("(injected fault)");
312305
}
313306
}
314307

@@ -379,7 +372,7 @@ describe("DocumentLinter", () => {
379372

380373
crashedProcesses.clear(); // Avoid out-of-memory errors.
381374
}
382-
});
375+
}, /*timeout=*/ 60_000);
383376
});
384377

385378
describe("ExhaustiveRNG", () => {

0 commit comments

Comments
 (0)