We are building our ChatGPT app using Next.js. I cannot include a link in this post, but it’s from the /vercel-labs/chatgpt-apps-sdk-nextjs-starter repo on Github.
When the widget is being rendered, we are intermittently experiencing the following error, and the widget fails to load:
Uncaught (in promise) InvariantError: Invariant: Expected document.currentScript to be a <script> element. Received [object HTMLScriptElement] instead. This is a bug in Next.js.
The error is thrown here, during the Next.js app bootstrapping process. I cannot include links in this post, but it’s in /packages/next/src/client/asset-prefix.ts#L6-L10
Sometimes when reloading the widget will render fine. Other times, the same error occurs and it fails to load.
I wonder if there is some kind of problem with the way the sandbox is rendering the HTML document?
I’ve filed a ticket with the repo at /vercel-labs/chatgpt-apps-sdk-nextjs-starter/issues/19 as well.
