Skip to content

Commit 8130017

Browse files
authored
Merge pull request #15 from O-Labz/memory-management-bug-fixes
fixed bugs
2 parents aa7c184 + acec87c commit 8130017

1 file changed

Lines changed: 20 additions & 21 deletions

File tree

src/core/indexer.ts

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -242,37 +242,36 @@ export class Indexer extends EventEmitter {
242242
parsed = await parseFile(relativePath, repositoryId, this.workspaceRoot);
243243
}
244244

245-
// Batch all graph writes in a single transaction for atomicity + performance
245+
// Remove existing nodes from file before adding new ones
246246
await this.graph.removeNodesInFile(relativePath);
247247

248-
await this.storage.transaction(async () => {
249-
// Bulk persist nodes (so resolveEdges' findByName lookups see them)
250-
await this.graph.bulkLoad(parsed.nodes, []);
251-
252-
// Resolve edges now that nodes are persisted
253-
const edges = this.resolveEdges(parsed, repositoryId);
254-
255-
// Bulk persist edges (single cache invalidation)
256-
await this.graph.bulkLoad([], edges);
257-
258-
// Track pending forward references
259-
this.pendingReferences.push({
260-
calls: parsed.calls,
261-
imports: parsed.imports,
262-
inheritance: parsed.inheritance,
263-
repositoryId,
264-
filePath: parsed.filePath,
265-
});
248+
// Bulk persist nodes (so resolveEdges' findByName lookups see them)
249+
await this.graph.bulkLoad(parsed.nodes, []);
250+
251+
// Resolve edges now that nodes are persisted
252+
const edges = this.resolveEdges(parsed, repositoryId);
253+
254+
// Bulk persist edges (single cache invalidation)
255+
await this.graph.bulkLoad([], edges);
256+
257+
// Track pending forward references
258+
this.pendingReferences.push({
259+
calls: parsed.calls,
260+
imports: parsed.imports,
261+
inheritance: parsed.inheritance,
262+
repositoryId,
263+
filePath: parsed.filePath,
264+
});
266265

267-
// Update file metadata
266+
// Update file metadata in a transaction
267+
this.storage.transaction(() => {
268268
fileMetadata.hash = parsed.hash;
269269
fileMetadata.language = parsed.language;
270270
fileMetadata.nodeCount = parsed.nodes.length;
271271
fileMetadata.status = 'indexed';
272272
fileMetadata.lastError = undefined;
273273
fileMetadata.indexedAt = new Date();
274274
fileMetadata.updatedAt = new Date();
275-
276275
fileMetadata.embeddingStatus = 'pending';
277276
this.storage.upsertFile(fileMetadata);
278277
});

0 commit comments

Comments
 (0)