grepmax 0.7.31 → 0.7.32
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.
|
@@ -77,6 +77,8 @@ const DEBOUNCE_MS = 2000;
|
|
|
77
77
|
const FTS_REBUILD_INTERVAL_MS = 5 * 60 * 1000;
|
|
78
78
|
function startWatcher(opts) {
|
|
79
79
|
const { projectRoot, vectorDb, metaCache, dataDir, onReindex } = opts;
|
|
80
|
+
const projectName = path.basename(projectRoot);
|
|
81
|
+
const wtag = `watch:${projectName}`;
|
|
80
82
|
const pending = new Map();
|
|
81
83
|
const retryCount = new Map();
|
|
82
84
|
let debounceTimer = null;
|
|
@@ -96,7 +98,7 @@ function startWatcher(opts) {
|
|
|
96
98
|
binaryInterval: 10000,
|
|
97
99
|
});
|
|
98
100
|
watcher.on("error", (err) => {
|
|
99
|
-
console.error(
|
|
101
|
+
console.error(`[${wtag}] Watcher error:`, err);
|
|
100
102
|
});
|
|
101
103
|
const scheduleBatch = () => {
|
|
102
104
|
if (debounceTimer)
|
|
@@ -111,13 +113,13 @@ function startWatcher(opts) {
|
|
|
111
113
|
processing = true;
|
|
112
114
|
const batchTimeout = setTimeout(() => {
|
|
113
115
|
if (processing) {
|
|
114
|
-
console.error(
|
|
116
|
+
console.error(`[${wtag}] Batch processing timed out after 120s, resetting`);
|
|
115
117
|
processing = false;
|
|
116
118
|
}
|
|
117
119
|
}, BATCH_TIMEOUT_MS);
|
|
118
120
|
const batch = new Map(pending);
|
|
119
121
|
pending.clear();
|
|
120
|
-
(0, logger_1.log)(
|
|
122
|
+
(0, logger_1.log)(wtag, `Processing ${batch.size} changed files`);
|
|
121
123
|
const start = Date.now();
|
|
122
124
|
let reindexed = 0;
|
|
123
125
|
const changedIds = [];
|
|
@@ -188,7 +190,11 @@ function startWatcher(opts) {
|
|
|
188
190
|
reindexed++;
|
|
189
191
|
}
|
|
190
192
|
else {
|
|
191
|
-
console.error(`[
|
|
193
|
+
console.error(`[${wtag}] Failed to process ${absPath}:`, err);
|
|
194
|
+
if (!pool.isHealthy()) {
|
|
195
|
+
console.error(`[${wtag}] Worker pool unhealthy, aborting batch`);
|
|
196
|
+
break;
|
|
197
|
+
}
|
|
192
198
|
}
|
|
193
199
|
}
|
|
194
200
|
}
|
|
@@ -216,10 +222,11 @@ function startWatcher(opts) {
|
|
|
216
222
|
finally {
|
|
217
223
|
yield lock.release();
|
|
218
224
|
}
|
|
225
|
+
const duration = Date.now() - start;
|
|
219
226
|
if (reindexed > 0) {
|
|
220
|
-
const duration = Date.now() - start;
|
|
221
227
|
onReindex === null || onReindex === void 0 ? void 0 : onReindex(reindexed, duration);
|
|
222
228
|
}
|
|
229
|
+
(0, logger_1.log)(wtag, `Batch complete: ${batch.size} files, ${reindexed} reindexed (${(duration / 1000).toFixed(1)}s)`);
|
|
223
230
|
consecutiveLockFailures = 0;
|
|
224
231
|
for (const absPath of batch.keys()) {
|
|
225
232
|
retryCount.delete(absPath);
|
|
@@ -230,7 +237,7 @@ function startWatcher(opts) {
|
|
|
230
237
|
if (isLockError) {
|
|
231
238
|
consecutiveLockFailures++;
|
|
232
239
|
}
|
|
233
|
-
console.error(
|
|
240
|
+
console.error(`[${wtag}] Batch processing failed:`, err);
|
|
234
241
|
let dropped = 0;
|
|
235
242
|
for (const [absPath, event] of batch) {
|
|
236
243
|
const count = ((_a = retryCount.get(absPath)) !== null && _a !== void 0 ? _a : 0) + 1;
|
|
@@ -244,7 +251,7 @@ function startWatcher(opts) {
|
|
|
244
251
|
}
|
|
245
252
|
}
|
|
246
253
|
if (dropped > 0) {
|
|
247
|
-
console.warn(`[
|
|
254
|
+
console.warn(`[${wtag}] Dropped ${dropped} file(s) after ${MAX_RETRIES} failed retries`);
|
|
248
255
|
}
|
|
249
256
|
if (pending.size > 0) {
|
|
250
257
|
const backoffMs = Math.min(DEBOUNCE_MS * Math.pow(2, consecutiveLockFailures), 30000);
|
|
@@ -320,7 +327,7 @@ function startWatcher(opts) {
|
|
|
320
327
|
yield vectorDb.createFTSIndex();
|
|
321
328
|
}
|
|
322
329
|
catch (err) {
|
|
323
|
-
console.error(
|
|
330
|
+
console.error(`[${wtag}] FTS rebuild failed:`, err);
|
|
324
331
|
}
|
|
325
332
|
}), FTS_REBUILD_INTERVAL_MS);
|
|
326
333
|
ftsInterval.unref();
|
package/dist/lib/workers/pool.js
CHANGED
package/package.json
CHANGED