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

[Bug]: Cannot read properties of undefined (reading 'data') index.js:234:29 #371

Closed
VovaTereschenko opened this issue Apr 17, 2023 · 7 comments
Labels
bug Something isn't working

Comments

@VovaTereschenko
Copy link

What happened?

Steps to reproduce

  1. install https://www.npmjs.com/package/chromadb v1.3.1 (didn't reproduce on v1.2.0)
  2. use the most basic starter (same happens without using OpenAIEmbeddingFunction)
import { ChromaClient, OpenAIEmbeddingFunction } from "chromadb";

const chroma = new ChromaClient();
const embedder = new OpenAIEmbeddingFunction('API_KEY');

const collection = await chroma.createCollection("testing-chrome", {}, embedder);

await collection.add(
  ["id1", "id2"],
  undefined,
  [{ source: "source_one" }, { source: "source_one" }],
  ["Question", "Answer"]
);

const result = await collection.query(undefined, 2, undefined, [
  "Answer appears",
]);

console.log("result", result);
  1. receive the error below
TypeError: Cannot read properties of undefined (reading 'data')
    at /Users/macbook/Developer/chroma-test/node_modules/chromadb/dist/main/index.js:234:29
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async ChromaClient.createCollection (/Users/macbook/Developer/chroma-test/node_modules/chromadb/dist/main/index.js:229:31)
    at async file:///Users/macbook/Developer/chroma-test/index.js:9:20

Versions

chroma v1.3.1, node v18.16.0, openai v3.2.1.

Relevant log output

No response

@VovaTereschenko VovaTereschenko added the bug Something isn't working label Apr 17, 2023
@VovaTereschenko
Copy link
Author

Just to reduce the possible confusion – same happens with this example:

import { ChromaClient } from "chromadb";
const chroma = new ChromaClient("http://localhost:8000");
const collection = await chroma.createCollection("test-from-js");
for (let i = 0; i < 20; i++) {
  await collection.add("test-id-" + i.toString(), [1, 2, 3, 4, 5], {
    test: "test",
  });
}
const queryData = await collection.query([1, 2, 3, 4, 5], 5, { test: "test" });

@grishick
Copy link
Contributor

As far as I can see, this happens when chroma-db is not actually running on localhost:8000. I got this exact error when I didn't start the chroma container. After I started chroma container, the exact code snippet that you posted above worked.

@AlexanderKozhevin
Copy link

AlexanderKozhevin commented Apr 18, 2023

yea, looks like connection error.
make sure db is running.
I had the same thing

@VovaTereschenko
Copy link
Author

VovaTereschenko commented Apr 18, 2023

You're @grishick @AlexanderKozhevin right, thx! Tho I'd rather throw an error e.g.Error: connect ECONNREFUSED; response from server to save some time.

@grishick
Copy link
Contributor

I think there is still a minor bug here - connection errors should be handled more gracefully with more informative message. I'd be happy to add a PR to handle that, but I also see there is an open PR for replacing axios with fetch, which should be merged first.

@jeffchuber
Copy link
Contributor

@grishick thanks! that would be great.

I was just able to land #292 today. Next up is that axios swap as you noted.

@tonisives
Copy link
Contributor

tonisives commented May 5, 2023

I have to say I still have this issue. And I know docker chroma is running, because it works with version 1.3.1.

There are no messages in the server for my TS code:

import { ChromaClient } from 'chromadb'

export const run = async () => {
  const chroma = new ChromaClient("http://localhost:8000");
  const collection = await chroma.createCollection("test-from-js");
}
run().then(() => console.log("finished"))

It doesn't work with 1.4.1 and 1.4.0.
Works with 1.3.1

Then server logs

2023-05-05 09:08:15 INFO     uvicorn.access  172.18.0.1:50196 - "POST /api/v1/collections HTTP/1.1" 200
2023-05-05 09:10:04 WARNING  chromadb.api.models.Collection No embedding_function provided, using default embedding function: SentenceTransformerEmbeddingFunction
2023-05-05 09:10:04 INFO     uvicorn.access  172.18.0.1:40998 - "POST /api/v1/collections HTTP/1.1" 200

edit:
I made another test project without typescript, and it works there with 1.4.1 as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants