Skip to content

Commit 5e4d640

Browse files
authored
fix totalChars accumulator for undefined pageContent (#2619)
1 parent 6fb775f commit 5e4d640

File tree

1 file changed

+6
-1
lines changed
  • packages/server/src/services/documentstore

1 file changed

+6
-1
lines changed

packages/server/src/services/documentstore/index.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,12 @@ const _saveChunksToStorage = async (data: IDocumentStoreLoaderForPreview, entity
600600
await appServer.AppDataSource.getRepository(DocumentStoreFileChunk).delete({ docId: newLoaderId })
601601
if (response.chunks) {
602602
//step 8: now save the new chunks
603-
const totalChars = response.chunks.reduce((acc: number, chunk) => acc + chunk.pageContent.length, 0)
603+
const totalChars = response.chunks.reduce((acc, chunk) => {
604+
if (chunk.pageContent) {
605+
return acc + chunk.pageContent.length
606+
}
607+
return acc
608+
}, 0)
604609
response.chunks.map(async (chunk: IDocument, index: number) => {
605610
const docChunk: DocumentStoreFileChunk = {
606611
docId: newLoaderId,

0 commit comments

Comments
 (0)