Fix file deletion handling during lint
MODIFY
packages/@romejs/core/server/WorkerManager.ts
packages/@romejs/core/server/WorkerManager.ts
@@ -313,11 +313,7 @@ export default class WorkerManager {
// Give memoryFs a chance to finish initializing if it's in a pending project
await this.server.memoryFs.waitIfInitializingWatch(path);
- stats = memoryFs.getFileStats(path);
- if (stats === undefined) {
- console.error(Array.from(memoryFs.files.keys(), (path) => path.join()));
- throw new Error(`The file ${path.join()} doesn't exist`);
- }
+ stats = memoryFs.getFileStatsAssert(path);
}
// Verify that this file doesn't exceed any size limit

MODIFY
packages/@romejs/core/server/dependencies/DependencyGraph.ts
packages/@romejs/core/server/dependencies/DependencyGraph.ts
@@ -295,15 +295,17 @@ export default class DependencyGraph {
analyzeProgress.pushText(progressText);
}
- const res: WorkerAnalyzeDependencyResult = await this.request.requestWorkerAnalyzeDependencies(
- path,
- {},
- );
+ let res: WorkerAnalyzeDependencyResult;
+ let node: DependencyNode;
+ try {
+ res = await this.request.requestWorkerAnalyzeDependencies(path, {});
- const node = this.addNode(path, res);
+ node = this.addNode(path, res);
node.setAll(all);
node.setUsedAsync(async);
+ } finally {
lock.release();
+ }
const {dependencies, diagnostics} = res;

MODIFY
packages/@romejs/core/server/fs/FileAllocator.ts
packages/@romejs/core/server/fs/FileAllocator.ts
@@ -172,7 +172,7 @@ export default class FileAllocator {
lock.release();
return this.getOwnerAssert(path);
}
-
+ try {
const worker = await workerManager.getNextWorker(path);
// Add ourselves to the file map
@@ -183,9 +183,10 @@ export default class FileAllocator {
);
this.fileToWorker.set(filename, worker.id);
+ return worker;
+ } finally {
// Release and continue
lock.release();
-
- return worker;
+ }
}
}

MODIFY
packages/@romejs/core/server/linter/Linter.ts
packages/@romejs/core/server/linter/Linter.ts
@@ -245,7 +245,7 @@ class LintRunner {
});
for (const path of evictedPaths) {
- await queue.pushQueue(path);
+ await FileNotFound.allowMissing(path, () => queue.pushQueue(path));
}
await queue.spin();
@@ -299,9 +299,12 @@ class LintRunner {
// Build a list of dependents to recheck
for (const path of evictedPaths) {
- validatedDependencyPaths.add(path);
+ const newNode = graph.maybeGetNode(path);
- const newNode = graph.getNode(path);
+ if (newNode === undefined) {
+ continue;
+ }
+ validatedDependencyPaths.add(path);
// Get the previous node and see if the exports have actually changed
const oldNode = oldEvictedNodes.get(path);

Fix file deletion handling during lint (#611)