speccrew 0.7.39 → 0.7.40

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "speccrew",
3
- "version": "0.7.39",
3
+ "version": "0.7.40",
4
4
  "description": "Spec-Driven Development toolkit for AI-powered IDEs",
5
5
  "author": "charlesmu99",
6
6
  "repository": {
@@ -152,7 +152,7 @@ function acquireLock(filePath) {
152
152
  try {
153
153
  const lockStat = fs.statSync(lockPath);
154
154
  const ageSeconds = (Date.now() - lockStat.mtimeMs) / 1000;
155
- if (ageSeconds > 120) {
155
+ if (ageSeconds > 30) {
156
156
  console.error(`Warning: Stale lock file detected (age: ${Math.round(ageSeconds)}s), removing: ${lockPath}`);
157
157
  fs.unlinkSync(lockPath);
158
158
  // Do not consume retry count, continue to next loop attempt to acquire lock
@@ -161,10 +161,32 @@ function acquireLock(filePath) {
161
161
  } catch (statErr) {
162
162
  // Lock file was deleted during stat, continue retrying
163
163
  }
164
+ } else {
165
+ // Non-EEXIST error (EACCES, EPERM, etc.) - log for debugging
166
+ if (retryCount === 0) {
167
+ console.error(`Warning: Lock creation failed with ${error.code} for: ${lockPath}`);
168
+ }
164
169
  }
165
170
  retryCount++;
166
171
  if (retryCount >= maxRetries) {
167
- throw new Error(`Failed to acquire file lock for '${filePath}' after ${maxRetries} attempts`);
172
+ // Force acquire as last resort
173
+ try {
174
+ // Remove any existing lock file regardless of age
175
+ if (fs.existsSync(lockPath)) {
176
+ fs.unlinkSync(lockPath);
177
+ }
178
+ // Brief random delay to avoid thundering herd on force acquire
179
+ const forceDelay = Math.floor(Math.random() * 500);
180
+ const forceStart = Date.now();
181
+ while (Date.now() - forceStart < forceDelay) {}
182
+
183
+ const fd = fs.openSync(lockPath, 'wx');
184
+ fs.closeSync(fd);
185
+ console.error(`Warning: Lock acquired by force after ${maxRetries} retries for: ${filePath}`);
186
+ return lockPath;
187
+ } catch (forceErr) {
188
+ throw new Error(`Failed to acquire file lock for '${filePath}' after ${maxRetries} attempts (force acquire also failed: ${forceErr.code})`);
189
+ }
168
190
  }
169
191
  // Retry with jitter to avoid thundering herd
170
192
  const delay = 200 + Math.floor(Math.random() * 300);