fix(smoke): wait for the server before deleting its data directory (#1858)

The java smoke flakes on teardown: the run.test.ts afterEach kills
openidea-server and immediately removes its home directory, but jdtls's
JVM is still shutting down inside it, so rmdir fails ENOTEMPTY. Now
close() resolves once the process exits, and the removal retries for
ten seconds instead of one.
Цей коміт міститься в:
arookieofc authored and GitHub committed 2026-11-07 00:16:14 +08:00
1 джерело 148ae62681
коміт 6e18f32a32
2 files changed
+13 -6

No files matched your search

+5 -3
Переглянути файл
@@ -128,12 +128,14 @@ let server: Server | null = null;
let disconnect: (() => void) | null = null;
let base = "";
afterEach(() => {
afterEach(async () => {
// As switching projects does: run ids restart with each server.
resetRuns();
disconnect?.();
server?.close();
if (base) rmSync(base, { recursive: true, force: true, maxRetries: 5, retryDelay: 200 });
await server?.close();
// A language server's own process (jdtls's JVM) can outlive the server's for a moment:
// deleting its data directory has to wait for it.
if (base) rmSync(base, { recursive: true, force: true, maxRetries: 10, retryDelay: 1000 });
});
async function open(c: Case): Promise<string> {
+8 -3
Переглянути файл
@@ -78,9 +78,14 @@ export class Server {
}
}
close() {
this.child.stdin.end();
this.child.kill();
/** Kills the server; resolves once the process is gone (its children may still be exiting). */
async close(): Promise<void> {
if (this.child.exitCode === null && !this.child.killed) {
const exited = new Promise<void>((resolve) => this.child.once("exit", () => resolve()));
this.child.stdin.end();
this.child.kill();
await exited;
}
}
private request(method: string, params: unknown): Promise<unknown> {