Skip to content

Commit a3be817

Browse files
committed
fix(project): Prevent post-destroy builds and EBUSY on Windows in integration tests
- Add #destroyed flag to BuildServer to prevent new builds from being triggered after destroy() is called - Clear pending build queue and timeout before awaiting active build to avoid race with setTimeout-based queue processing - Add maxRetries to rmrf in integration tests for Windows file handle release delays after SQLite close
1 parent 67df3d5 commit a3be817

3 files changed

Lines changed: 8 additions & 3 deletions

File tree

packages/project/lib/build/BuildServer.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ class BuildServer extends EventEmitter {
4444
#pendingBuildRequest = new Set();
4545
#activeBuild = null;
4646
#processBuildRequestsTimeout;
47+
#destroyed = false;
4748
#allReader;
4849
#rootReader;
4950
#dependenciesReader;
@@ -124,6 +125,10 @@ class BuildServer extends EventEmitter {
124125
}
125126

126127
async destroy() {
128+
this.#destroyed = true;
129+
// Prevent any queued builds from starting after shutdown
130+
clearTimeout(this.#processBuildRequestsTimeout);
131+
this.#pendingBuildRequest.clear();
127132
await this.#watchHandler.destroy();
128133
if (this.#activeBuild) {
129134
// Await active build to finish
@@ -313,7 +318,7 @@ class BuildServer extends EventEmitter {
313318
}
314319

315320
#triggerRequestQueue() {
316-
if (this.#activeBuild) {
321+
if (this.#destroyed || this.#activeBuild) {
317322
return;
318323
}
319324
// If no build is active, trigger queue processing debounced

packages/project/test/lib/build/BuildServer.integration.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ function getTmpPath(folderName) {
364364
}
365365

366366
async function rmrf(dirPath) {
367-
return fs.rm(dirPath, {recursive: true, force: true});
367+
return fs.rm(dirPath, {recursive: true, force: true, maxRetries: 3, retryDelay: 200});
368368
}
369369

370370
class FixtureTester {

packages/project/test/lib/build/ProjectBuilder.integration.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2460,7 +2460,7 @@ function getTmpPath(folderName) {
24602460
}
24612461

24622462
async function rmrf(dirPath) {
2463-
return fs.rm(dirPath, {recursive: true, force: true});
2463+
return fs.rm(dirPath, {recursive: true, force: true, maxRetries: 3, retryDelay: 200});
24642464
}
24652465

24662466
class FixtureTester {

0 commit comments

Comments
 (0)