[Bug] Breaking change for Bun runtime between v1.0.1 and v1.1.1
Is this a new bug?
- [X] I believe this is a new bug
- [X] 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
- Install pinecone package (v.1.1.x) and create a file with the snippet given above.
- Run it with
nodeand confirm it works. - Run it with
bunand confirm it throws an error. - 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.
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.
Hello, are there any updates on this?
any updates on this?
Still broken :'(
Confirming this is still broken here as well.
gg still broken on 1.1.18
+1
Still broken
Any updates or workarounds?
Still broken
Any updates or workarounds?
My workaround for the time being is to use Cohere (or Elastic Search): https://cohere.com