mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-02-04 09:13:08 +00:00
ok one final pr to remove gemini-found race condition
This commit is contained in:
@@ -170,22 +170,8 @@ class FeatureLoader {
|
|||||||
const featureJsonPath = this.getFeatureJsonPath(projectPath, featureId);
|
const featureJsonPath = this.getFeatureJsonPath(projectPath, featureId);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Check if feature.json exists before trying to read it
|
// Read feature.json directly - handle ENOENT in catch block
|
||||||
try {
|
// This avoids TOCTOU race condition from checking with fs.access first
|
||||||
await fs.access(featureJsonPath);
|
|
||||||
} catch (accessError) {
|
|
||||||
// File doesn't exist - this is expected for incomplete feature directories
|
|
||||||
// Skip silently or log at debug level only
|
|
||||||
if (accessError.code !== "ENOENT") {
|
|
||||||
console.warn(
|
|
||||||
`[FeatureLoader] Cannot access feature.json for ${featureId}:`,
|
|
||||||
accessError.message
|
|
||||||
);
|
|
||||||
}
|
|
||||||
// Skip this directory - it doesn't have a valid feature.json
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
const content = await fs.readFile(featureJsonPath, "utf-8");
|
const content = await fs.readFile(featureJsonPath, "utf-8");
|
||||||
const feature = JSON.parse(content);
|
const feature = JSON.parse(content);
|
||||||
|
|
||||||
@@ -201,10 +187,9 @@ class FeatureLoader {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
// Handle different error types appropriately
|
// Handle different error types appropriately
|
||||||
if (error.code === "ENOENT") {
|
if (error.code === "ENOENT") {
|
||||||
// File was deleted between access check and read - skip silently
|
// File doesn't exist - this is expected for incomplete feature directories
|
||||||
console.debug(
|
// Skip silently (feature.json not yet created or was removed)
|
||||||
`[FeatureLoader] Feature ${featureId} was removed, skipping`
|
continue;
|
||||||
);
|
|
||||||
} else if (error instanceof SyntaxError) {
|
} else if (error instanceof SyntaxError) {
|
||||||
// JSON parse error - log as warning since file exists but is malformed
|
// JSON parse error - log as warning since file exists but is malformed
|
||||||
console.warn(
|
console.warn(
|
||||||
|
|||||||
Reference in New Issue
Block a user