-
Notifications
You must be signed in to change notification settings - Fork 986
Closed as duplicate
Closed as duplicate
Copy link
Description
Operating System
ArchLinux (though this is not OS dependent)
Environment (if applicable)
Node v22.18.0
Firebase SDK Version
12.1.0
Firebase SDK Product(s)
AI
Project Tooling
React app with webpack
Detailed Problem Description
When I have an AI agent, I get this error often after the agent has done a couple of tool calls:
Cannot read properties of undefined (reading 'some')
TypeError: Cannot read properties of undefined (reading 'some')
at http://localhost:3000/static/js/bundle.js:194967:35
at Array.forEach (<anonymous>)
at mapGenerateContentCandidates (http://localhost:3000/static/js/bundle.js:194945:16)
at mapGenerateContentResponse (http://localhost:3000/static/js/bundle.js:194906:47)
at processGenerateContentResponse (http://localhost:3000/static/js/bundle.js:195242:12)
at async generateContent (http://localhost:3000/static/js/bundle.js:195233:35)
at async ChatSession.sendMessage (http://localhost:3000/static/js/bundle.js:195564:5)
at async http://localhost:3000/static/js/bundle.js:7659:16
at async http://localhost:3000/static/js/bundle.js:7726:7
The error seems to come from this line specifically:
| candidate.content?.parts.some( |
Basically, it appears that under certain conditions, the parts may be undefined. But it's unclear to me why.
Steps and code to reproduce issue
Here's my ChatWidget:
Basically, if I do a query that evokes a tool response which fetches a large file which is then returned to the agent, this error occurs. Though it doesn't seem to be consistent always. I almost feel like I'm being rate-limited, but the error is pretty cryptic and I'm not sending that many tokens through the model.