[GH-ISSUE #541] Bug (Showstopper type): TypeError: tokenChunks.slice is not a function #318

Closed
opened 2026-02-22 18:18:55 -05:00 by yindo · 1 comment
Owner

Originally created by @pritchey on GitHub (Jan 5, 2024).
Original GitHub issue: https://github.com/Mintplex-Labs/anything-llm/issues/541

The following entry in the Docker log output provides the clue:

2024-01-05 12:22:08 TypeError: tokenChunks.slice is not a function
2024-01-05 12:22:08 at cannonball (/app/server/utils/helpers/chat/index.js:307:34)
2024-01-05 12:22:08 at /app/server/utils/helpers/chat/index.js:143:29
2024-01-05 12:22:08 at new Promise ()
2024-01-05 12:22:08 at messageArrayCompressor (/app/server/utils/helpers/chat/index.js:102:29)
2024-01-05 12:22:08 at LMStudioLLM.compressMessages (/app/server/utils/AiProviders/lmStudio/index.js:187:18)
2024-01-05 12:22:08 at streamChatWithWorkspace (/app/server/utils/chats/stream.js:98:39)
2024-01-05 12:22:08 at async /app/server/endpoints/chat.js:76:9

Looking at the file /app/server/utils/helpers/chat/index.js, specifically line 307 shows this:

const leftChunks = tokenChunks.slice(0, middleIdx - Math.round(delta / 2));

Digging backwards through the code, the tokenChunks is an integer value, not an array, therefore doesn't support the slice method to split the array into parts.

Originally created by @pritchey on GitHub (Jan 5, 2024). Original GitHub issue: https://github.com/Mintplex-Labs/anything-llm/issues/541 The following entry in the Docker log output provides the clue: 2024-01-05 12:22:08 TypeError: tokenChunks.slice is not a function 2024-01-05 12:22:08 at cannonball (/app/server/utils/helpers/chat/index.js:307:34) 2024-01-05 12:22:08 at /app/server/utils/helpers/chat/index.js:143:29 2024-01-05 12:22:08 at new Promise (<anonymous>) 2024-01-05 12:22:08 at messageArrayCompressor (/app/server/utils/helpers/chat/index.js:102:29) 2024-01-05 12:22:08 at LMStudioLLM.compressMessages (/app/server/utils/AiProviders/lmStudio/index.js:187:18) 2024-01-05 12:22:08 at streamChatWithWorkspace (/app/server/utils/chats/stream.js:98:39) 2024-01-05 12:22:08 at async /app/server/endpoints/chat.js:76:9 Looking at the file /app/server/utils/helpers/chat/index.js, specifically line 307 shows this: const leftChunks = tokenChunks.slice(0, middleIdx - Math.round(delta / 2)); Digging backwards through the code, the tokenChunks is an integer value, not an array, therefore doesn't support the slice method to split the array into parts.
yindo added the bug label 2026-02-22 18:18:55 -05:00
yindo closed this issue 2026-02-22 18:18:55 -05:00
Author
Owner

@timothycarambat commented on GitHub (Jan 5, 2024):

Great catch, that was my fault. Will need to start building tests around those methods to prevent this

@timothycarambat commented on GitHub (Jan 5, 2024): Great catch, that was my fault. Will need to start building tests around those methods to prevent this
yindo changed title from Bug (Showstopper type): TypeError: tokenChunks.slice is not a function to [GH-ISSUE #541] Bug (Showstopper type): TypeError: tokenChunks.slice is not a function 2026-06-05 14:34:40 -04:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Mintplex-Labs/anything-llm#318