Open VistritPandey opened 1 month ago
did you resolve this error
Getting the same error but just implementing the @vercel/ai
library myself.
It seems to be related to the fact that sometimes, > 1 tool call happens - which means that after the 1st tool call closes the stream via .done()
, the second tool call cannot append values to this stream.
That's just my hunch, anyway.
Full error:
web:dev: [0] Error: .done(): Value stream is already closed.
web:dev: [0] at assertStream (webpack-internal:///(action-browser)/../../node_modules/ai/rsc/dist/rsc-server.mjs:1196:19)
web:dev: [0] at Object.done (webpack-internal:///(action-browser)/../../node_modules/ai/rsc/dist/rsc-server.mjs:1309:13)
web:dev: [0] at Object.execute (webpack-internal:///(action-browser)/./app/google-analytics/actions.tsx:90:36)
web:dev: [0] at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
web:dev: [0] at async eval (webpack-internal:///(action-browser)/../../node_modules/ai/dist/index.mjs:1293:22)
web:dev: [0] at async Promise.all (index 0)
web:dev: [0] at async executeTools (webpack-internal:///(action-browser)/../../node_modules/ai/dist/index.mjs:1287:23)
web:dev: [0] at async generateText (webpack-internal:///(action-browser)/../../node_modules/ai/dist/index.mjs:1252:47)
web:dev: [0] at async continueConversation (webpack-internal:///(action-browser)/./app/google-analytics/actions.tsx:49:45)
web:dev: [0] at async /Users/me/project/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:39:418
web:dev: [0] at async rw (/Users/me/project/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:38:7978)
web:dev: [0] at async r4 (/Users/me/project/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:41:1251)
web:dev: [0] at async doRender (/Users/me/project/node_modules/next/dist/server/base-server.js:1438:30)
web:dev: [0] at async cacheEntry.responseCache.get.routeKind (/Users/me/project/node_modules/next/dist/server/base-server.js:1599:28)
web:dev: [0] at async DevServer.renderToResponseWithComponentsImpl (/Users/me/project/node_modules/next/dist/server/base-server.js:1507:28)
web:dev: [0] at async DevServer.renderPageComponent (/Users/me/project/node_modules/next/dist/server/base-server.js:1931:24)
web:dev: [0] at async DevServer.renderToResponseImpl (/Users/me/project/node_modules/next/dist/server/base-server.js:1969:32)
web:dev: [0] at async DevServer.pipeImpl (/Users/me/project/node_modules/next/dist/server/base-server.js:920:25)
web:dev: [0] at async NextNodeServer.handleCatchallRenderRequest (/Users/me/project/node_modules/next/dist/server/next-server.js:272:17)
web:dev: [0] at async DevServer.handleRequestImpl (/Users/me/project/node_modules/next/dist/server/base-server.js:816:17)
web:dev: [0] at async /Users/me/project/node_modules/next/dist/server/dev/next-dev-server.js:339:20
web:dev: [0] at async Span.traceAsyncFn (/Users/me/project/node_modules/next/dist/trace/trace.js:154:20)
web:dev: [0] at async DevServer.handleRequest (/Users/me/project/node_modules/next/dist/server/dev/next-dev-server.js:336:24)
web:dev: [0] at async invokeRender (/Users/me/project/node_modules/next/dist/server/lib/router-server.js:174:21)
web:dev: [0] at async handleRequest (/Users/me/project/node_modules/next/dist/server/lib/router-server.js:353:24)
web:dev: [0] at async requestHandlerImpl (/Users/me/project/node_modules/next/dist/server/lib/router-server.js:377:13)
web:dev: [0] at async Server.requestListener (/Users/me/project/node_modules/next/dist/server/lib/start-server.js:141:13)
web:dev: [0] ⨯ ../streamable.tsx (292:13) @ assertStream
web:dev: [0] ⨯ Error: .error(): Value stream is already closed.
web:dev: [0] at captureError (./app/google-analytics/actions.tsx:46:16)
web:dev: [0] at Object.execute (./app/google-analytics/actions.tsx:94:25)
web:dev: [0] at async Promise.all (index 0)
web:dev: [0] at async continueConversation (./app/google-analytics/actions.tsx:49:45)
web:dev: [0] digest: "1566680405"
web:dev: [0] 290 | function assertStream(method: string) {
web:dev: [0] 291 | if (closed) {
web:dev: [0] > 292 | throw new Error(method + ': Value stream is already closed.');
web:dev: [0] | ^
web:dev: [0] 293 | }
web:dev: [0] 294 | if (locked) {
web:dev: [0] 295 | throw new Error(
yeah, I thought the .done() may be a problem, but I don't think that is, because even if I get that warning, I still get a response as intended. Also for the error, where it is not showing anything at all, it seems to be completely occasional. The worst part about all of it is that there is no way to track the issue properly, which leads to the question of whether this has something to do with the deployment environment or something completely different. But at the same time, I remember seeing this issue on Vercel as well but ignored it thinking that it may be because of my free plan
I'm paying for Vercel, so I don't think that's the problem. And for me when this happened, I received no response, as the error just crashes the app. Let's post about this on the main https://github.com/vercel/ai repo?
I deployed my project on Google Cloud Run, and am receiving this error Error: .update(): Value stream is already closed.
This happens very occasionally, but because of that, I cannot see the stream coming in. However when I refresh that page after some time, it shows the generated text, and in some cases it does not (which may be in the cases when it did not complete the stream to be able to save it, and I refreshed the page)
Is there a fix for this issue? I was seeing this issue on the vercel as well, and it is not necessarily something I see all the time, but sometimes its too frequent