code-graph-context 2.10.0 → 2.10.1

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.
@@ -6,7 +6,7 @@
6
6
  import { debugLog } from '../../mcp/utils.js';
7
7
  import { getEmbeddingSidecar } from './embedding-sidecar.js';
8
8
  const BATCH_CONFIG = {
9
- maxBatchSize: 16, // Small batches — 1.5B model on MPS has limited VRAM
9
+ maxBatchSize: 8, // Small batches — 1.5B model on MPS OOMs at higher values on 16GB machines
10
10
  };
11
11
  export class LocalEmbeddingsService {
12
12
  async embedText(text) {
@@ -20,12 +20,14 @@ export class LocalEmbeddingsService {
20
20
  return sidecar.embed(texts);
21
21
  }
22
22
  async embedTextsInBatches(texts, batchSize = BATCH_CONFIG.maxBatchSize) {
23
+ // Cap batch size — callers (e.g. graph-generator) may pass 100 which OOMs the local model
24
+ const safeBatchSize = Math.min(batchSize, BATCH_CONFIG.maxBatchSize);
23
25
  await debugLog('Batch embedding started', { provider: 'local', textCount: texts.length });
24
26
  const sidecar = getEmbeddingSidecar();
25
27
  const results = [];
26
- const totalBatches = Math.ceil(texts.length / batchSize);
27
- for (let i = 0; i < texts.length; i += batchSize) {
28
- const batch = texts.slice(i, i + batchSize);
28
+ const totalBatches = Math.ceil(texts.length / safeBatchSize);
29
+ for (let i = 0; i < texts.length; i += safeBatchSize) {
30
+ const batch = texts.slice(i, i + safeBatchSize);
29
31
  const batchIndex = Math.floor(i / batchSize) + 1;
30
32
  await debugLog('Embedding batch progress', {
31
33
  provider: 'local',
@@ -124,11 +124,13 @@ process.on('uncaughtException', async (error) => {
124
124
  console.error(JSON.stringify({ level: 'error', message: 'Uncaught exception', error: String(error), stack: error.stack }));
125
125
  await debugLog('Uncaught exception', { error: String(error), stack: error.stack });
126
126
  await logServerStats('uncaught-exception');
127
+ await stopEmbeddingSidecar();
127
128
  });
128
129
  process.on('unhandledRejection', async (reason) => {
129
130
  console.error(JSON.stringify({ level: 'error', message: 'Unhandled rejection', reason: String(reason) }));
130
131
  await debugLog('Unhandled rejection', { reason: String(reason) });
131
132
  await logServerStats('unhandled-rejection');
133
+ await stopEmbeddingSidecar();
132
134
  });
133
135
  // Log other process events that might indicate issues
134
136
  process.on('warning', async (warning) => {
@@ -137,6 +139,7 @@ process.on('warning', async (warning) => {
137
139
  process.on('beforeExit', async (code) => {
138
140
  await debugLog('Process beforeExit', { code });
139
141
  await logServerStats('before-exit');
142
+ await stopEmbeddingSidecar();
140
143
  });
141
144
  process.on('exit', (code) => {
142
145
  // Note: Can't use async here, exit is synchronous
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "code-graph-context",
3
- "version": "2.10.0",
3
+ "version": "2.10.1",
4
4
  "description": "MCP server that builds code graphs to provide rich context to LLMs",
5
5
  "type": "module",
6
6
  "homepage": "https://github.com/drewdrewH/code-graph-context#readme",