Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unhandled Runtime Error — Cannot read properties of undefined (reading 'function_call') #9

Closed
rohanikshvaku opened this issue Aug 5, 2023 · 1 comment

Comments

@rohanikshvaku
Copy link

rohanikshvaku commented Aug 5, 2023

I get this error as soon as I send a message:

Error Cannot read properties of undefined (reading 'function_call')
let finalResponse;
 
>  if (initialResponseMessage.function_call) {
                               ^ (this arrow is at the dot between these words)
  58 |     const { name, arguments: args } = initialResponseMessage.function_call;
  59 |     const functionResponse = await runFunction(name, JSON.parse(args));
Unhandled Runtime Error
Error: <!DOCTYPE html><html><head><meta charSet="utf-8"/><link rel="preload" as="script" 
href="/_next/static/chunks/webpack.js?ts=1691270902524"/><link rel="preload" as="script" 
href="/_next/static/chunks/main.js?ts=1691270902524"/><link rel="preload" as="script" 
href="/_next/static/chunks/pages/_app.js?ts=1691270902524"/><link rel="preload" as="script" 
href="/_next/static/chunks/pages/_error.js?ts=1691270902524"/><link rel="preload" as="script" 
href="/_next/static/development/_buildManifest.js?ts=1691270902524"/><link rel="preload" as="script" 
href="/_next/static/development/_ssgManifest.js?ts=1691270902524"/><link rel="preload" as="script" 
href="/_next/static/chunks/react-refresh.js?ts=1691270902524"/><meta name="viewport" content="width=device-width"/>
<meta name="next-head-count" content="2"/><style data-next-hide-fouc="true">body{display:none}</style><noscript data-
next-hide-fouc="true"><style>body{display:block}</style></noscript><noscript data-n-css=""></noscript><script defer="" 
noModule="" src="/_next/static/chunks/polyfills.js?ts=1691270902524"></script><script src="/_next/static/chunks/webpack.js?
ts=1691270902524" defer=""></script><script src="/_next/static/chunks/main.js?ts=1691270902524" defer=""></script>
<script src="/_next/static/chunks/pages/_app.js?ts=1691270902524" defer=""></script><script 
src="/_next/static/chunks/pages/_error.js?ts=1691270902524" defer=""></script><script 
src="/_next/static/development/_buildManifest.js?ts=1691270902524" defer=""></script><script 
src="/_next/static/development/_ssgManifest.js?ts=1691270902524" defer=""></script><noscript 
id="__next_css__DO_NOT_USE__"></noscript></head><body><div id="__next"></div><script 
src="/_next/static/chunks/react-refresh.js?ts=1691270902524"></script><script id="__NEXT_DATA__" 
type="application/json">{"props":{"pageProps":{"statusCode":500}},"page":"/_error","query":
{"__NEXT_PAGE":"/api/chat"},"buildId":"development","isFallback":false,"err":{"name":"TypeError","source":"edge-
server","message":"Cannot read properties of undefined (reading 'function_call')","stack":"TypeError: Cannot read properties of 
undefined (reading 'function_call')\n    at POST (webpack-internal:///(sc_server)/./app/api/chat/route.ts:35:32)\n    at 
process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n    at async eval (webpack-
internal:///(sc_server)/./node_modules/.pnpm/next@13.4.7_react-
dom@18.2.0_react@18.2.0/node_modules/next/dist/esm/server/future/route-modules/app-
route/module.js:229:37)"},"gip":true,"scriptLoader":[]}</script></body></html>

My env file is setup properly and I've tried renaming it to .env.local too but it doesn't work.

@rohanikshvaku
Copy link
Author

I fixed this, also I just created a pull request with improved error logging, which should help debug these issues faster.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant