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] Breaking change for Bun runtime between v1.0.1 and v1.1.1 #141

Open
2 tasks done
erhant opened this issue Oct 17, 2023 · 4 comments
Open
2 tasks done

[Bug] Breaking change for Bun runtime between v1.0.1 and v1.1.1 #141

erhant opened this issue Oct 17, 2023 · 4 comments
Labels
bug Something isn't working

Comments

@erhant
Copy link

erhant commented Oct 17, 2023

Is this a new bug?

  • I believe this is a new bug
  • I have searched the existing issues, and I could not find an existing issue for this bug

Current Behavior

Consider the following code:

const { Pinecone } = require("@pinecone-database/pinecone");
const apiKey = "your-api-key";
const environment = "your-env";
const indexName = "your-index";

async function main() {
  const pinecone = new Pinecone({
    apiKey,
    environment,
  });
  await pinecone.describeIndex(indexName);
  const index = pinecone.index(indexName);

  // some random query vector
  const arr = Array.from({ length: 1536 }, () => Math.random());

  await index.query({
    vector: arr,
    topK: 50,
    includeValues: true, // it is important that this is `true`!
    includeMetadata: true,
  });
}

main().then(() => process.exit(0));

When we run this script with node index.js we have no problems. However, when we run it with bun index.js it throws an error:

❯ bun index.js
499 |             var _a;
500 |             return __generator(this, function (_b) {
501 |                 switch (_b.label) {
502 |                     case 0:
503 |                         _a = this.transformer;
504 |                         return [4 /*yield*/, this.raw.json()];
                                                 ^
SyntaxError: Unexpected end of JSON input
      at /Users/erhant/fb/tmp/pinecone-bug/node_modules/@pinecone-database/pinecone/dist/pinecone-generated-ts-fetch/runtime.js:504:45
      at step (/Users/erhant/fb/tmp/pinecone-bug/node_modules/@pinecone-database/pinecone/dist/pinecone-generated-ts-fetch/runtime.js:72:17)
      at /Users/erhant/fb/tmp/pinecone-bug/node_modules/@pinecone-database/pinecone/dist/pinecone-generated-ts-fetch/runtime.js:53:52
      at /Users/erhant/fb/tmp/pinecone-bug/node_modules/@pinecone-database/pinecone/dist/pinecone-generated-ts-fetch/runtime.js:47:8
      at new Promise (:1:20)
      at /Users/erhant/fb/tmp/pinecone-bug/node_modules/@pinecone-database/pinecone/dist/pinecone-generated-ts-fetch/runtime.js:43:11
      at /Users/erhant/fb/tmp/pinecone-bug/node_modules/@pinecone-database/pinecone/dist/pinecone-generated-ts-fetch/runtime.js:498:15
      at /Users/erhant/fb/tmp/pinecone-bug/node_modules/@pinecone-database/pinecone/dist/pinecone-generated-ts-fetch/apis/VectorOperationsApi.js:405:45
      at step (/Users/erhant/fb/tmp/pinecone-bug/node_modules/@pinecone-database/pinecone/dist/pinecone-generated-ts-fetch/apis/VectorOperationsApi.js:84:17)

Expected Behavior

It should not throw an error when working with Bun.

To go further, I have edited the code at the point of error to see exactly what is going on. Beginning at line 502 I have modified it as:

case 0:
  const t = this.raw.text();
  _a = this.transformer;
  return [4 /*yield*/, t
    .then(t => JSON.parse(t))
    .catch(e => {
      t.then(t => console.log({obj: t, type: typeof t}))
      throw e
    })
  ];

which should do the same thing as this.raw.json() but allow us to see the body before throwing an error. This way, we see that with Bun we print the following within the catch function:

❯ bun index.js
{
  obj: "",
  type: "string"
}
502 |                     case 0:
503 |                         const t = this.raw.text();
504 |                         _a = this.transformer;
505 |                         return [4 /*yield*/, t
506 |                           .then(t => JSON.parse(t))
507 |                           .catch(e => {
                                          ^
SyntaxError: JSON Parse error: Unexpected EOF
      at /Users/erhant/fb/tmp/pinecone-bug/node_modules/@pinecone-database/pinecone/dist/pinecone-generated-ts-fetch/runtime.js:507:38

In other words, something causes the body to be empty string, which of course can't be parsed to JSON.

This issue does not exist for pinecone client v.1.0.1.

Steps To Reproduce

  1. Install pinecone package (v.1.1.x) and create a file with the snippet given above.
  2. Run it with node and confirm it works.
  3. Run it with bun and confirm it throws an error.
  4. Optionally, install pinecone package (v.1.0.x) and see that it works for both.

It seems to be important that includeValues is set to be true.

Relevant log output

No response

Environment

- **OS**: macOS Ventura 13.0
- **Language version**: Bun: 1.0.4 and Node: 20.5.0
- **Pinecone client version**: 1.1.1

Additional Context

Here is a shortcut to Bun issues page: https://github.com/oven-sh/bun/issues

They have quite a lot of issues, but if we can pinpoint what causes the issue with Pinecone we can link to a relevant issue within Bun. Perhaps a different method was used to parse the request body between v1.0.1 ~ v.1.1.1 and Bun does not support the latter?

Mentioning my teammate @anilaltuner to also notify him & for his help on finding the bug.

@jhamon
Copy link
Collaborator

jhamon commented Oct 19, 2023

Thank you for the detailed bug report. I will try to look at this soon and add some bun integration tests so this doesn't happen again.

@erhant
Copy link
Author

erhant commented Nov 30, 2023

Hello, are there any updates on this?

@knajjars
Copy link

knajjars commented Jan 6, 2024

any updates on this?

austin-denoble added a commit that referenced this issue Jan 12, 2024
## Problem
Bun has been a rapidly emerging toolkit for developing, testing,
running, and bundling Javascript and TypeScript. We currently have an
outstanding GH issue related to the bun runtime:
#141. It would
be nice to add some coverage in CI for running our integration tests
with bun as the runner.

@jhamon kicked this work off a while ago and I wanted to make sure we
got this included.

## Solution
- Update `/github/workflows/testing.yml` and add a new `config` section
to the `integration-tests` matrix. Tests will now be run with `npm` in
node and edge, and `bun` with node for bun versions `1.0.4` -> `1.0.7`.

## Type of Change
- [X] Infrastructure change (CI configs, etc)

## Test Plan
Make sure all the integration tests are 🟢 in CI.
austin-denoble added a commit that referenced this issue Jan 13, 2024
## Problem
Bun has been a rapidly emerging toolkit for developing, testing,
running, and bundling Javascript and TypeScript. We currently have an
outstanding GH issue related to the bun runtime:
#141. It would
be nice to add some coverage in CI for running our integration tests
with bun as the runner.

@jhamon kicked this work off a while ago and I wanted to make sure we
got this included.

## Solution
- Update `/github/workflows/testing.yml` and add a new `config` section
to the `integration-tests` matrix. Tests will now be run with `npm` in
node and edge, and `bun` with node for bun versions `1.0.4` -> `1.0.7`.

## Type of Change
- [X] Infrastructure change (CI configs, etc)

## Test Plan
Make sure all the integration tests are 🟢 in CI.
@noahgsolomon
Copy link

Still broken :'(

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

4 participants