[ErrorWithoutStackTrace: PineconeClient: Error calling upsert: TypeError: stream.getReader is not a function]

Hey all. I have a Next.js app and implementing Pinecone the following way:

import { PineconeClient, Vector } from "@pinecone-database/pinecone";

export async function uploadToPinecone(embeddings, rows) {
  await pinecone.init({ apiKey, environment });
  const index = pinecone.Index("main-index");
  const vectors = rows.map((row, i) => ({
    id: i,
    values: embeddings,
  }));
  const upsertRequest = { vectors, namespace: "main-namespace" };
  await index.upsert({ upsertRequest });
}

I have tried:

  • moving the function directly to the /api route
  • next.js config settings to render pages static
  • packages like into-stream for readable streams (was assuming that wouldnt work)

I was wondering about compatibility with next.js but then I saw the pinecone example using next.js.

I have tried many different ways to resolve this error but am not finding any luck. Any ideas?

1 Like

I am experiencing the same issue on both upsert and createIndex.

I switched to the API and that worked for now

1 Like

ran into this issue as well. can you clarify how you fixed the issue? thanks!

Same here - any pointers on how to solve it?

Make sure you are running on Node 18.

I got the same error when running on Node 16

1 Like

I found the reason!
The id field shouldn’t is number type instead string type.
This is weird bug forPineconeClient npm package bug. @alexcheuk @Oskar

This was my issue as well

For me the problem was with the length of the vector I was feeding it, being shorter than what’s configured in the index

1 Like