fix: chunk indexing en import dynamique — ne casse plus notes.ts si p-queue/migration absent
Les imports statiques de chunkIndexingService dans notes.ts et clip/save causaient un crash du module entier si la table NoteEmbeddingChunk n'existait pas en production. Maintenant les imports sont dynamiques ( await import() ) avec try-catch — les notes fonctionnent même si le chunk indexing est indisponible.
This commit is contained in:
@@ -8,7 +8,6 @@ import { getAIProvider } from '@/lib/ai/factory'
|
||||
import { parseNote, getHashColor } from '@/lib/utils'
|
||||
import { upsertNoteEmbedding } from '@/lib/embeddings'
|
||||
import { embeddingService } from '@/lib/ai/services/embedding.service'
|
||||
import { chunkIndexingService } from '@/lib/ai/services/chunk-indexing.service'
|
||||
import { syncNoteLinksForNote } from '@/lib/notes/sync-note-links'
|
||||
import { getSystemConfig, getConfigNumber, getConfigBoolean, SEARCH_DEFAULTS } from '@/lib/config'
|
||||
import { contextualAutoTagService } from '@/lib/ai/services/contextual-auto-tag.service'
|
||||
@@ -460,6 +459,7 @@ export async function createNote(data: {
|
||||
}
|
||||
|
||||
try {
|
||||
const { chunkIndexingService } = await import('@/lib/ai/services/chunk-indexing.service')
|
||||
await chunkIndexingService.indexNote(noteId, data.title, content)
|
||||
} catch (e) {
|
||||
console.error('[BG] Chunk indexing failed:', e)
|
||||
@@ -605,6 +605,7 @@ export async function updateNote(id: string, data: {
|
||||
}
|
||||
|
||||
try {
|
||||
const { chunkIndexingService } = await import('@/lib/ai/services/chunk-indexing.service');
|
||||
await chunkIndexingService.indexNote(noteId, title, content);
|
||||
} catch (e) {
|
||||
console.error('[BG] Chunk indexing failed:', e);
|
||||
|
||||
@@ -6,7 +6,6 @@ import { createNotification } from '@/app/actions/notifications'
|
||||
import { buildClipSourceFooter, clipFooterLocaleTag } from '@/lib/clip/extract-article'
|
||||
import { resolveClipLocale, wrapClipArticleHtml, applyRtlToHtmlBlocks } from '@/lib/clip/rtl-content'
|
||||
import { embeddingService } from '@/lib/ai/services/embedding.service'
|
||||
import { chunkIndexingService } from '@/lib/ai/services/chunk-indexing.service'
|
||||
import { upsertNoteEmbedding } from '@/lib/embeddings'
|
||||
import DOMPurify from 'isomorphic-dompurify'
|
||||
|
||||
@@ -94,7 +93,10 @@ export async function POST(request: NextRequest) {
|
||||
await upsertNoteEmbedding(note.id, embedding)
|
||||
}
|
||||
|
||||
await chunkIndexingService.indexNote(note.id, title || domain, fullContent)
|
||||
try {
|
||||
const { chunkIndexingService } = await import('@/lib/ai/services/chunk-indexing.service')
|
||||
await chunkIndexingService.indexNote(note.id, title || domain, fullContent)
|
||||
} catch {}
|
||||
} catch (error) {
|
||||
console.error('[clip/save] embedding generation failed:', error)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user