@softerist/heuristic-mcp 2.1.44 → 2.1.45

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.
@@ -150,17 +150,21 @@ export class CodebaseIndexer {
150
150
  }
151
151
  } catch (err) {
152
152
  console.error(`[Indexer] Worker initialization failed: ${err.message}, falling back to single-threaded`);
153
- this.terminateWorkers();
153
+ await this.terminateWorkers();
154
154
  }
155
155
  }
156
156
 
157
157
  /**
158
158
  * Terminate all worker threads
159
159
  */
160
- terminateWorkers() {
161
- for (const worker of this.workers) {
162
- worker.postMessage({ type: "shutdown" });
163
- }
160
+ async terminateWorkers() {
161
+ const terminations = this.workers.map((worker) => {
162
+ try {
163
+ worker.postMessage({ type: "shutdown" });
164
+ } catch {}
165
+ return worker.terminate().catch(() => null);
166
+ });
167
+ await Promise.all(terminations);
164
168
  this.workers = [];
165
169
  this.workerReady = [];
166
170
  }
@@ -730,7 +734,7 @@ export class CodebaseIndexer {
730
734
 
731
735
  // Cleanup workers
732
736
  if (useWorkers) {
733
- this.terminateWorkers();
737
+ await this.terminateWorkers();
734
738
  }
735
739
 
736
740
  const totalTime = ((Date.now() - totalStartTime) / 1000).toFixed(1);
package/index.js CHANGED
@@ -248,6 +248,11 @@ process.on('SIGINT', async () => {
248
248
  console.error("[Server] File watcher stopped");
249
249
  }
250
250
 
251
+ // Terminate workers to avoid native crashes on exit
252
+ if (indexer && indexer.terminateWorkers) {
253
+ await indexer.terminateWorkers();
254
+ }
255
+
251
256
  // Save cache
252
257
  if (cache) {
253
258
  await cache.save();
@@ -267,6 +272,11 @@ process.on('SIGTERM', async () => {
267
272
  console.error("[Server] File watcher stopped");
268
273
  }
269
274
 
275
+ // Terminate workers to avoid native crashes on exit
276
+ if (indexer && indexer.terminateWorkers) {
277
+ await indexer.terminateWorkers();
278
+ }
279
+
270
280
  // Save cache
271
281
  if (cache) {
272
282
  await cache.save();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@softerist/heuristic-mcp",
3
- "version": "2.1.44",
3
+ "version": "2.1.45",
4
4
  "description": "An enhanced MCP server providing intelligent semantic code search with find-similar-code, recency ranking, and improved chunking. Fork of smart-coding-mcp.",
5
5
  "type": "module",
6
6
  "main": "index.js",